我正在写一本js AWS Lambda Function 。
我会请求API而不js event.body 进
行测试
export const check = async (event) => {
try{
console.log("it does work");
const {email, uid} = JSON.parse(event.body); // email and uid both would be undefined..
//JSON.parse() throw some Error, so the below codes doesn't work.
//Also, I can't see any single word from the response.
if(!email && !uid) throw "No body data!"; // I expected throw this string but it didn't happend
return {
statusCode: 200,
body: JSON.stringify({msg: "SUCCESS"})
}
}catch(e){
return {
statusCode: 500,
body: JSON.stringify({e: e})
}
}
}
我可以得到这个回应。
{
e: {}
}
我想看看
{
e: "Some sentences about Error caused by JSON.parse() or No body data!"
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。