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.

Revisions

  1. AlexSKuznetsov revised this gist Jun 22, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Method Override в Express JS
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    npm i method-override

    const methodOverride = require(‘method-override’)

    // Разрешает использовать PUT, DELETE с формами.
  2. AlexSKuznetsov created this gist Jun 22, 2020.
    11 changes: 11 additions & 0 deletions Method Override в Express JS
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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;
    }
    }));