Firebase - Firestore set method is promise but then or catch doesn't work

Viewed 149

Firestore neither fires then or catch after setting a value in a collection.

Not working example is - https://stackblitz.com/edit/angular-ivy-w4fmak

this.counter++;
this.afs.doc(`users/kGYry149A9Vou57KzMcYPqJmupN2`).set({
      name: "Los Angeles_"+this.counter,
      state: "CA",
      country: "USA"
    })
      .then(function () {
        this.name = 'one_'+ this.counter;
        console.log("Document successfully written!");
      })
      .catch(function (error) {
        this.name = 'two_'+ this.counter;
        console.error("Error writing document: ", error);
      })
0 Answers
Related