each then 28 29 should return a value or throw

Solutions on MaxInterview for each then 28 29 should return a value or throw by the best coders in the world

showing results for - "each then 28 29 should return a value or throw"
Karl
25 Aug 2020
1outer.get('/account', function(req, res) {
2  var id = req.user.uid
3  var userRef = firebase.db.collection('users').doc(id)
4  var profilePromise = userRef.get().then(doc => {
5    if (doc.exists) {
6      var profile = doc.data()
7      profile.id = doc.id
8      return profile // I assume you don't want to return undefined
9//    ^^^^^^
10    } else {
11      throw new Error("Profile doesn't exist")
12//    ^^^^^
13    }
14  })
15  // More promises further on, which I wait for:
16  // profilePromise.then(myProfile => { … });
17})
18