In my firebase app i've made it so a user can send an email to another user. I've got a node server listening for these requests and sending them through FireBase and the Trigger Email extension. Once i insert a document like this --
admin
.firestore()
.collection("mail")
.add({
to: `${req.body.toEmail}`,
message: {
subject: "here is a subject",
html: `here is a message`,
},
})
.then((response) => {
return res.status(200).json({
message: "email sent!"
});
Trigger Email does some magic (I think it's utilizing a cloud function) to then begin to update the document once it's created.
The document will get updated with a property called state that will either be ERROR or SUCCESS. I need to wait until that field gets added and updated before returning a response to the client.
Anyone dealt with this before?