我有以下JavaScript代码:
members.reduce((chain, el) => {
return chain
.then(() => db.collection("users").doc(el).collection("user_data").doc("u").get())
.then(doc => {
const data = doc.data();
// do some stuff
return table_number;
})
.then(table_num => {
return db.collection("users").doc(el).collection("grades").doc("g").collection(education_part).get().then(function (querySnapshot) {
querySnapshot.forEach(function (doc) {
const data = doc.data();
//DO SOME STUFF AGAIN AFTER FIRST TASK FINISHED
});
})
})
}, Promise.resolve());
所有这些任务完成后如何解雇?预先感谢
〜filip
编辑
这是//完成第一个任务后再次进行的一些填充。这是同步的,但是此解决方案}, Promise.resolve()).then(console.log("finished"));
甚至无效。
var filteredMDl = 0, filteredKLU = 0, local_averagePoints = 0;
addToTable("grade_table" + table_num, doc.id, filteredMDl, filteredKLU, local_averagePoints);
//Adds data to an HTML table