如何使用bodyParser JSON节点JS + Express?

时间:2015-02-16 02:58:25

标签: javascript json node.js heroku express

帮我发送{"simple": "json"},然后我回来{ }

var express = require('express');

var app = express();

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

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

app.set('port', (process.env.PORT || 5000));

app.use(express.static(__dirname + '/public'));

app.post('/', function (req, res) {
   console.log(req.body);
   res.json(req.body);
})

0 个答案:

没有答案