我正在尝试从我的 firebase db 表中删除投票,据我所知,这是一个需要时间的异步请求,尽管我的函数早于结束,所以我收到以下错误 -Ignoring exception from a finished function这是我的功能代码 -function continueDeleteFromFirebaseVotesDB(videoId, contestId) { console.log("before query declaration"); var query = database.ref("votes/" + contestId).orderByKey(); console.log("before foreach loop") query.once(value) .then(function (snapshot) { console.log("inside foreach loop") if (!snapshot.exists) { console.log("votes db snapshot does not exist"); return; } snapshot.forEach(function (childSnapshot) { //var key = childSnapshot.key; // childData will be the actual contents of the child var childData = childSnapshot.val(); if (childData.video_id === contestId) { childSnapshot.ref.remove(); console.log("removed vote - " + JSON.stringify(childSnapshot)) continueDeleteFromFirebaseVideosDB(videoId) } }); return query; }) .then(function (data) { console.log(JSON.stringify(data)); })}为了使我的函数异步并等待结果,我缺少什么?
添加回答
举报
0/150
提交
取消