Firebase cloud function promises

前端 未结 2 1491
有刺的猬
有刺的猬 2020-12-22 09:48

I\'m having a hard time getting a promise chain to flow correctly in a firebase cloud function. It loops through a ref and returns an array of emails for sending out notific

2条回答
  •  粉色の甜心
    2020-12-22 10:12

    Instead of dealing with all the promises from the inner query inline and pushing the emails into an array, you should be pushing the promises into an array and using Promise.all() to wait until they're all done. Then, iterate the array of snapshots to build the array of emails.

    You may find my tutorials on working with promises in Cloud Functions to be helpful in learning some of the techniques: https://firebase.google.com/docs/functions/video-series/

提交回复
热议问题