Skip to content

Instantly share code, notes, and snippets.

@makefunstuff
Created March 4, 2017 23:26
Show Gist options
  • Save makefunstuff/3dc8c5a7117c4ac8bf311a856a0d1677 to your computer and use it in GitHub Desktop.
Save makefunstuff/3dc8c5a7117c4ac8bf311a856a0d1677 to your computer and use it in GitHub Desktop.
app.get('/data/:id/filtered', (req, res, next) => {
const { id } = req.params;
database.getById(id)
.then((data) => {
logger('[INFO] data is received');
tracking('data.received', {id: id});
return data;
})
.then((data) => dataFilterService({id: data}))
.then((apiResult) => {
logger('[INFO] data is filtered');
tracking('api.result.received');
res.json(apiResult);
})
.catch((error) => {
logger('[ERROR] ', error.message);
exceptionCatcher(error);
res.status(500).json({
error: 'Something went wrong'
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment