【发布时间】:2018-03-04 18:47:30
【问题描述】:
为什么我总是进入我的 firebase 控制台“Promise { pending }”?
我很确定我正确地使用了带有“.then”的承诺概念。我的函数有什么问题? (由亚历山大主教编辑)
exports.GenerateLiveGameIfAllPlayerReady = functions.database.ref("games/lobby/{pushId}/playerList/{playerId}").onUpdate(event => {
//Get the object of the game then put it in the Live games node
const transfertNewLiveGame = event.data.ref.parent.parent.once('value').then(snap => {
return snap.val();
}).then(() => {
console.log(transfertNewLiveGame);
console.log(event.params.pushId);
return admin.database().ref('games/live').update({
[event.params.pushId]: transfertNewLiveGame
});
})
【问题讨论】:
标签: node.js firebase-realtime-database google-cloud-functions