Created
January 30, 2021 11:52
-
-
Save jinalshah999/9bba693c435c3115dccf82979c67e7c6 to your computer and use it in GitHub Desktop.
This file contains 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
bindResponse(req, res, next) { | |
this.request = req; | |
res.sendResponse = (response) => { | |
res.json({ | |
status: 'success', | |
data: response | |
}); | |
}; | |
res.sendError = (error) => { | |
if(error.httpCode) { | |
res.status(error.httpCode); | |
} | |
res.json({ | |
status: 'error', | |
error: error.code ? error.getError(): error | |
}); | |
}; | |
next(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment