I have tried in many ways. The code works when I test from the AWS console but when I try with Postman it does not run.
exports.main = async function handler(event) {
event.Records.filter( async (record) => {
if (record.eventName.toUpperCase() === "INSERT") {
const recordType = record.dynamodb.NewImage.type.S;
if (recordType.toUpperCase() === "TASKTYPE") {
// here I get the arguments value. Works fine.
await submitSearchTask(keyword, key, tag); // it also get called. No problem
}
}
});
};
Submit Search Function
const submitSearchTask = async function handler(keyword, key, tag) {
const url = "***"; // the endpoint works fine.
const response = await fetch(url, {
method: "POST",
headers: getDfsRequestHeader(),// getDfsRequestHeader() also works fine
body: JSON.stringify(getPostArray(keyword, tag)),// getPostArray() also works
});
const result = await response.json();
console.log(result) // it does not work. Nothing showed in the cloudwatch log
const taskId = result.tasks[0].id;// locally it works fine
console.log(taskId); // it does not work. Nothing showed in the cloud watch log
};
I will highly appreciate any help and guidance.