Created
March 4, 2017 23:26
-
-
Save makefunstuff/3dc8c5a7117c4ac8bf311a856a0d1677 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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