Last active
August 29, 2015 13:57
-
-
Save ryansukale/9434680 to your computer and use it in GitHub Desktop.
A simple template of node post - using multiparty instead of bodyparser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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