SGR
0
Q:

method override npm

app.use(methodOverride(function (req, res) {
  if (req.body && typeof req.body === 'object' && '_method' in req.body) {
    // look in urlencoded POST bodies and delete it
    var method = req.body._method
    delete req.body._method
    return method
  }
}))
0
using method-override in your index.js
1. npm install method-override --save
2. var methodOverride = require("method-override");
3. app.use(methodOverride("_method"));
//'_method' is what methodOverride will look for
method override in your UPDATE route: 
* <form action = "/campgrounds/<%=campground._id%>/edit?_method=PUT" 
	method = "POST">
and EDIT routes: 
0

New to Communities?

Join the community