Created
April 30, 2020 10:32
-
-
Save abegehr/db1aaa3692419ac584a71b6e640a93d6 to your computer and use it in GitHub Desktop.
Promise.then().catch(); Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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