0

I am trying to upload images to firebase storage and then when uploads finish, execute a try/catch block of codes with addDoc() command to create a doc inside fb database. The sample coding is as follows:

const abc = () => {

  array.map(() => {
    return uploadFilesToFb()
  })
  
  // then, when the above function finishes
  createDocInFb()
}

I heard about Promises, but is there any other way of doing this? I mean, in firebase there are .then functions but since I have a mapping I couldn't put addDoc() after .then of uploadFilesToFb(). If only alternative is promises, how can I achieve that with promises?

3
  • I’d take a step back and read up on async/await, promises in general, how to handle collections of asyncs, etc. It’ll pay off quickly. Commented Dec 12, 2022 at 18:11
  • @DaveNewton Yes I am now looking async/await. When used, warning comes: "'await' has no effect on the type of this expression." when I used it with mapping function. Commented Dec 12, 2022 at 18:28
  • It’s not clear what you tried. Commented Dec 12, 2022 at 21:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.