Guys I could use some help. I am a bit stuck.So I am trying to push an object to Firebase realtime databse and I have this piece of code.exports.create = async booking => {let id = guid.generate();let reservationNumber = await generateBookingNumber(booking.tripID);let trip = await tripUtil.getSingle(booking.tripID);await reference() .child(id) .set({ ...booking, reservationNumber, id }).then(() => {console.log('Successfully set');reference().orderByChild('id').equalTo(id).once('value').then(snap => {console.log(snap.val());return booking = snap.val(); }); });console.log(bookingCallback);// Variable and function for sending Twilio SMS// let holderPassenger = booking.passengers[0];// messages.sendOptionalConfirmationMessage(holderPassenger);// Variable and function for sending Email// emails.sendOptionalConfirmationEmail(booking, trip);return bookingCallback;}So I get the snapshot value inside .then() callback but I am not 100% sure how to return it so I can use it in email confirmation and to my function, because I am sending it to the client updated with the new data.
Submitted January 25, 2020 at 10:21PM by squizyt
No comments:
Post a Comment