Skip to content

Instantly share code, notes, and snippets.

@ryansukale
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save ryansukale/9434680 to your computer and use it in GitHub Desktop.

Select an option

Save ryansukale/9434680 to your computer and use it in GitHub Desktop.
A simple template of node post - using multiparty instead of bodyparser
/*
Apparently using bodyParser is bad
http://andrewkelley.me/post/do-not-use-bodyparser-with-express-js.html
This is how you'd fetch post parameters using multiparty instead.
*/
var multiparty = require('multiparty');
//Fetching the value of a field in a post parameter
app.post('/yoururl', function(req, res) {
console.log(req.method + ':'+ req.url);
var form = new multiparty.Form();
form.parse(req, function(err, fields, files) {
console.log(fields.fieldName);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment