Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js: methodOverride doesn't work

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.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js: methodOverride doesn't work

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×