Skip to content

Instantly share code, notes, and snippets.

@abegehr
Created April 30, 2020 10:32
Show Gist options
  • Save abegehr/db1aaa3692419ac584a71b6e640a93d6 to your computer and use it in GitHub Desktop.
Save abegehr/db1aaa3692419ac584a71b6e640a93d6 to your computer and use it in GitHub Desktop.
Promise.then().catch(); Example
// https://firebase.google.com/docs/firestore/quickstart
const userPromise = db.doc("user/" + uid).get().then(doc => {
if (doc.exists) {
console.log("User data:", doc.data());
// use fetched data, for example in setState()
} else {
console.warn("No user data.");
}
}).catch(error => {
console.log("Error getting user data:", error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment