跳到主要内容
CNode

superagent使用post服务器端无法接收到数据

问答
Sstop2stare发布于 10 年前最后回复 10 年前
345620

传数据

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)

S
stop2stare#310 年前
引用 cctv1005s用了中间件 body parser了吗?

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

S
stop2stare#210 年前
引用 cctv1005s用了中间件 body parser了吗?

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

C
cctv1005s#110 年前

用了中间件 body-parser了吗?

参与回复

登录后即可参与回复。登录