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?

JeremyFc
  • 53
  • 5
  • 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. – Dave Newton Dec 12 '22 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. – JeremyFc Dec 12 '22 at 18:28
  • It’s not clear what you tried. – Dave Newton Dec 12 '22 at 21:47

0 Answers0