Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda