Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ganeshkbhat/638ff33746f8f48b0c41a5ddf5de9975 to your computer and use it in GitHub Desktop.

Select an option

Save ganeshkbhat/638ff33746f8f48b0c41a5ddf5de9975 to your computer and use it in GitHub Desktop.
ExpressJS Series - Blocking Middlewares and Responding from the middleware
const myFirstMiddleware = function(req, res, next) {
 // Http request to server https://myexternalloggingserver.com/log
 someHTTPRequestLibrary.post('https://myexternalloggingserver.com/log', {body: req.path})
.then((data)=>{
  next();
 }, (err) =>{
res.status(500).send('Failed');
 });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment