Skip to content

Instantly share code, notes, and snippets.

@AlexSKuznetsov
Last active June 22, 2020 15:38
Show Gist options
  • Select an option

  • Save AlexSKuznetsov/988d220ba7375e592d3e1b59ecdc4bc6 to your computer and use it in GitHub Desktop.

Select an option

Save AlexSKuznetsov/988d220ba7375e592d3e1b59ecdc4bc6 to your computer and use it in GitHub Desktop.
npm i method-override
const methodOverride = require(‘method-override’)
// Разрешает использовать PUT, DELETE с формами.
app.use(methodOverride(function (req, res) {
if (req.body && typeof req.body === 'object' && '_method' in req.body) {
// look in urlencoded POST bodies and delete it
const method = req.body._method;
delete req.body._method;
return method;
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment