美文网首页
node.js中间件 body-parser

node.js中间件 body-parser

作者: 飞鱼_JS | 来源:发表于2017-05-30 18:35 被阅读0次

//第一步

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

//第二步

app.use(bodyParser.urlencoded({ extended: false })) // parse application/x-www-form-urlencoded 
app.use(bodyParser.json())// parse application/json 

//第三步(路由)

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

相关文章

网友评论

      本文标题:node.js中间件 body-parser

      本文链接:https://www.haomeiwen.com/subject/brvrfxtx.html