Skip to content

Instantly share code, notes, and snippets.

@sht5
Created June 28, 2017 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sht5/52390c50af9a0833c0fc72910223aa19 to your computer and use it in GitHub Desktop.
Save sht5/52390c50af9a0833c0fc72910223aa19 to your computer and use it in GitHub Desktop.
example of ExpressJS endpoint logging an http error
app.post('/user/defaultLanguage', (req, res) => {
const defaultLanguage = req.body.defaultLanguage;
const userEmail = req.user.email;
userLogic.updateUserDefaultLang(userEmail, defaultLanguage)
.then(() => {
res.end();
})
.catch((err) => {
utils.logHttpRequestError(res.req, err);
res.status(500).end();
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment