Created
March 8, 2019 07:05
-
-
Save jdgo-mars/f76aad961f0a2c3e4366a0d6e442bdcc 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
// Wrap an async function so we catch any errors that might occur | |
const wrapAsync = handler => (req, res) => | |
handler(req, res) | |
.then(result => res.json(result)) | |
.catch(error => res.status(500).json({ error: error.message })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment