扫码关注官方订阅号
ringa_lee
express解析body需要用到body-parser中间件
var express = require('express') var bodyParser = require('body-parser') var app = express() var jsonParser = bodyParser.json() var urlencodedParser = bodyParser.urlencoded({ extended: false }) app.post('/login', urlencodedParser, function (req, res) { if (!req.body) return res.sendStatus(400) res.send('welcome, ' + req.body.username) })
soonfy
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
express解析body需要用到body-parser中间件
soonfy