I'm trying to let this block of code execute after uploading data to firebase, but I get "execute after uploading data completed" before "Annotaion added" in console... Am I using async wrong here?
uploadData() .then(() => { console.log("execute after uploading data completed") //THIS BLOCK })
async function uploadData() { ..... //1. add to annotations //2. increment count in files //3. add to user's annotations db.collection("annotations") .doc(fileName) .set(updateField, { merge: true }) .then(() => { console.log("Annotation added!"); }) .catch((error) => { console.error("Error adding document: ", error); }); }
https://stackoverflow.com/questions/67377942/javascript-executing-block-after-getting-data-from-firestore May 04, 2021 at 10:15AM
没有评论:
发表评论