我已经搜索了几个小时了,我需要帮助。我想我没有用正确的词。无论如何,我使用Claudia.JS为我的AWS函数设置一个POST请求。下面是该函数的基本知识:
api.post('/leads', function (request) {
console.log(request);
return request;
});当我使用postman测试post请求时,就会返回request对象。太棒了。然后我试着传递表单数据。我将键设置为“用户名”,将值设置为“这是用户名”。这就是request.body的含义:
"body": "---------------------------
-019178618034620042564575\r\nContent-Disposition: form-data;
name=\"username\"\r\n\r\nthis is the username\r\n----------------------
------019178618034620042564575--\r\n",`我想我可以把request.body.username.要键入username...but的值,我遗漏了一些东西。
如何访问请求中的表单数据?
更新:好的。网站是采取表单数据,做一个帖子request...this功能是接收的帖子请求?尽管如此--在postman...if中,我要把我自己的JSON in...why --我不能像.request.body.username?
发布于 2017-09-18 07:11:09
您应该尝试使用console.log(request.data)来查看请求对象,即。在我自己的情况下,我可以看到我的请求的正文的内容。
查看sandbox,查看有关您的请求的所有相关信息。
发布于 2017-09-18 19:38:15
我通过查看邮递员中的标题来解决这个问题。它被设置为form-data,而不是application/JSON。现在全是肉汁了。
https://stackoverflow.com/questions/46247127
复制相似问题