Node.js: methodOverride doesn't work
Problem
In the server side:
var express = require('express');
var app = express();
app.listen(8000);
app.configure(function(){
app.use(express.methodOverride());
});
app.put('/update', function (req, res) {
res.send("update!");
})
I want test the put
method
in the client side:
but the result is
Cannot GET /update?_method=put
so, what's wrong with my code?
Problem courtesy of: hh54188
Solution
You need to include the bodyParser
middleware too:
app.use(express.bodyParser());
app.use(express.methodOverride());
Solution courtesy of: robertklep
Discussion
View additional discussion.