I am writing an AWS Lambda Function.
and I would request the API without event.body for test
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})
}
}
}
I could get this response.
{
e: {}
}
I want to see
{
e: "Some sentences about Error caused by JSON.parse() or No body data!"
}