Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Each then() should return a value or throw

outer.get('/account', function(req, res) {
  var id = req.user.uid
  var userRef = firebase.db.collection('users').doc(id)
  var profilePromise = userRef.get().then(doc => {
    if (doc.exists) {
      var profile = doc.data()
      profile.id = doc.id
      return profile // I assume you don't want to return undefined
//    ^^^^^^
    } else {
      throw new Error("Profile doesn't exist")
//    ^^^^^
    }
  })
  // More promises further on, which I wait for:
  // profilePromise.then(myProfile => { … });
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: mapStateProps 
Javascript :: regex check for anchor tag with specific text 
Javascript :: check install modules npm directory 
Javascript :: react hook form 
Javascript :: difference between js and jsx 
Javascript :: textbox value length in javascript 
Javascript :: is value in list javascript 
Javascript :: add int to string javascirpt 
Javascript :: how to search for react icons on vscode 
Javascript :: how to update mongodb collection with a new field 
Javascript :: what to use let vs var js 
Javascript :: inline null check javascript 
Javascript :: common javascript errors 
Javascript :: find second largest number in array javascript 
Javascript :: javascript array find case insensitive 
Javascript :: export multiple function in node js 
Javascript :: Get title assert 
Javascript :: dynamic input fields with radio button 
Javascript :: React native pdf creater html-to-pdf 
Javascript :: react form validation 
Javascript :: js regexp match 
Javascript :: javascript sort strings of object 
Javascript :: elastic search host using docker 
Javascript :: math.floor + roandom 
Javascript :: node get path of current file 
Javascript :: a full express function 
Javascript :: read string using stream nodejs 
Javascript :: what are escape characters in javascript 
Javascript :: eslint ignore javascript 
Javascript :: javascript allow only numbers in input alert 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =