set 404 handling via express in node
app.use(function(req, res, next){
res.status(404);
// respond with html page
if (req.accepts('html')) {
res.render('404', { url: req.url });
return;
}
// respond with json
if (req.accepts('json')) {
res.send({ error: 'Not found' });
return;
}
// default to plain-text. send()
res.type('txt').send('Not found');
});
Also in JavaScript:
- javascript object
- javascript length of number
- js json groupby prop
- angular access current scope from console
- javascript find object by property in array
- Exception in thread "main" org.openqa.selenium.JavascriptException:
- jquery copier dans le presse papier
- js standard global
- puppeteer stealth popup
- how to create show more item in javascript
- odoo post template form using js
- singly even magic square creation algorithm
- react clear input value
- accèder data-id javascript
- command to create react app
- ng-class equivalent in react
- json parse string
- mongoose custom object schema
- function inside object javascript
- get first element of array javascript
- react function called last state
- nested array loop in javascript
- video in react native stack overflow
- how to use json file in nodejs