Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs post req accept form data

var express = require('express');
var bodyParser = require('body-parser');
var app = express();

app.get('/', function(req, res){
   res.render('form');
});

// for parsing application/json
app.use(bodyParser.json()); 

// for parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true })); 

app.post('/', function(req, res){
   console.log(req.body);
   res.send("recieved your request!");
});

app.listen(3000);
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #nodejs #post #req #accept #form #data
ADD COMMENT
Topic
Name
3+4 =