Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
how I can return data as success message when I set data in firebase?

I try to return orderId after I set this order in Realtime database using angularfirestore what I should use after set() to return the orderId after sucess add this order to database

my order object is this:

const orderObj: Order = {
   payMethod: paymethod,
   arrivalHour: arrivalHour,
   tabel: this.tabel,
   itemsCount: Object.keys(this.handleCart.getCartData().items).length,
   state: { cook: false, serve: false, delete: false },
   items: this.handleCart.getCartData().items,
   orderId: new Date().toLocaleDateString(),
   addedOnDate: new Date().toLocaleDateString(),
   addedOnHour: new Date().toLocaleTimeString('en-US'),
   totalPrice: this.handleCart.getCartData().totalAmt,
};

and for set the data in database I use angular fire store as that :

 constructor(private store: AngularFirestore, private router: Router) {
   
store.collection('Orders').doc(this.data.Id).set(this.data)
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can wrap the db operation with a try catch and handle accordingly.

try {
    store.collection('Orders').doc(this.data.Id).set(this.data)
    return {
      docId: this.data.id
    }
} catch (error) {
   return {
      error,
      errorMessage: 'something went wrong'
   }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!