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:
<form action="/update">
<input type="hidden" name="_method" value="put"/>
<input type="submit" value="submit">
</form>
but the result is
Cannot GET /update?_method=put
so, what's wrong with my code?
You need to include the bodyParser
middleware too:
app.use(express.bodyParser());
app.use(express.methodOverride());