Middleware which logs error and sends to email.
npm install erroremail --save-dev
// Import our library
var erroremail = require('erroremail');
// App get
app.get('/example', (req, res, next)=>{
try {
res.json({"Happy Coding!"});
} catch(err){
next(err);
}
});
// Error Handler Middleware
app.use(erroremail('Gmail', '[email protected]', 'Gmail App Password'));
app.use(erroremail('Gmail', '[email protected]', 'Gmail App Password', '[email protected]'));
app.use(erroremail('Gmail', '[email protected]', 'Gmail App Password', ['[email protected]', '[email protected]']));