在我的无服务器应用程序中,我收到一个包含这样数据的请求
{
"captcha": "asdf"
}
我无法从请求正文中提取此数据。这是我的代码的样子:
module.exports.contact = (event, context, callback) => {
var body = querystring.parse(event.body);
var str = JSON.stringify(body);
var obj = JSON.parse(str); // I know this is horribly inefficient, just testing
if (!obj.hasOwnProperty('captcha'))
{
callback(null, {statusCode: 400, body: "No Captcha" + JSON.stringify(obj) + obj.captcha});
return;
}
我的无服务器端点发送以下响应正文:-
No Captcha{"{\n\"captcha\": \"asdf\"\n}":""}undefined
我认为因为我可以将 body 字符串化,将其解析为 obj,然后再次对其进行字符串化,并获得有效的 JSON,我应该能够获得 obj 属性验证码 - 但我不能......?