117

The Connect.js very terse documentation says methodOverride

Provides faux HTTP method support.

What does that mean? The obvious Google search is less than helpful. Why is methodOverride useful?

Pier-Luc Gendreau
  • 13,553
  • 4
  • 58
  • 69
Randomblue
  • 112,777
  • 145
  • 353
  • 547

1 Answers1

148
  • If you want to simulate DELETE and PUT, methodOverride is for that.
  • If you pass in the _method post parameter set to 'delete' or 'put', then you can use app.delete and app.put in Express instead of using app.post all the time (thus more descriptive, verbose):

Backend:

// the app
app.put('/users/:id', function (req, res, next) {
  // edit your user here
});

Client logic:

// client side must be..
<form> ...
  <input type="hidden" name="_method" value="put" />
</form>
bofredo
  • 2,348
  • 6
  • 32
  • 51
alessioalex
  • 62,577
  • 16
  • 155
  • 122
  • 5
    And the source should be [http://www.senchalabs.org/connect/methodOverride.html](http://www.senchalabs.org/connect/methodOverride.html) – ilyaigpetrov May 21 '13 at 06:45