Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ganeshkbhat/7ed31a21ad33c97b9cc0d0db319949d5 to your computer and use it in GitHub Desktop.

Select an option

Save ganeshkbhat/7ed31a21ad33c97b9cc0d0db319949d5 to your computer and use it in GitHub Desktop.
ExpressJS Series: Non-blocking middleware
const myFirstMiddleware = function(req, res, next) {
 someHTTPRequestLibraryOrPUBSUBLibrary.postOrRequest('https://myexternalloggingserver.com/log', {body: req.path})
.then((data)=>{
  console.log('Sent to logging server', data);
 }, (err) =>{
  console.log('Error Occured, log err to local file', err);
 })
 next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment