我正在嘗試從我的 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)); })}為了使我的函數異步并等待結果,我缺少什么?
忽略 Node JS 上已完成函數的異常
哈士奇WWW
2021-10-14 13:48:01