superagent使用post服务器端无法接收到数据
发布于 8 年前 作者 stop2stare 4021 次浏览 来自 问答

传数据

superagent
	.post('http://localhost:5100/api/todo')
	.send({
		id: 1111,
		content: 2222,
		complete: undefined
	})
	.end(function(res) {
		console.log(res)
	})

服务器

app.post('/api/todo', function(req, res, next) {
    console.log(req.body, req.query, req.params);
})

结果打印出来就是undefined {} {} 请问是哪里出错了?

3 回复

用了中间件 body-parser了吗?

@cctv1005s 我试试。。。桥豆麻袋。。

@cctv1005s 解决了。多谢。以前传参数的时候没有注意到使用这个,一直都OK的。我先去看看这个东西到底做什么用的。

回到顶部