Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

expressjs async await

app.post('/signup', async(req, res) => {
  try {
    const { email, firstName } = req.body
    const user = new User({ email, firstName })
    const ret = await user.save()
    res.json(ret)
  } catch (error) {
    console.log(error)
  }
})
Source by zellwk.com #
 
PREVIOUS NEXT
Tagged: #expressjs #async #await
ADD COMMENT
Topic
Name
1+6 =