- 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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…