0

I have the following code which works fine when the app is online . However when offline the code for the promise resolution or rejection doesn't get executed. I have googled the documentation for cloud firestore. I could find examples on querying the data offline but none on inserting data when the app is offline.Including only the relevant portions below.

db.collection('GroceryLists').doc().set(post).then(function () {
            callback();
            console.log('committed to the database');
            return Promise.resolve('commited to the database');
        }).catch(function (error) {
            //sometimes you get this error in the offline phase
            console.log('error is ', error);
            return Promise.reject('error is ' + error);
        });
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

The completion promise only fires after the data is committed or rejected on the server.

There is no event for when the data is committed to the client-side database, which is considered a temporary cache by Firestore.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807