@Alejandro2396 wrote:
What can I do so that the code of the application does not continue executing while doing the query to firebase, since it returns an empty value or creates a new id even if it exists. Thank you
iniciar_chat(idUsu1: string, idUsu2: string): string { let existeConversacion: boolean = false; let idChat: string = ""; this.afDB.database.ref().child('/chats-info') .orderByChild("idUsuers") .equalTo(idUsu1 + "_" + idUsu2) .on('child_added', (snapshot) => { existeConversation = true; idChat = snapshot.key; }); let datos_chat = { idUser1: idUsu1, idUser2: idUsu2, }; idChat = this.afDB.createPushId(); this.afDB.database.ref().child(`/chats-info/${ idChat }`).update(datos_chat); return idChat; }
Posts: 1
Participants: 1