My fetch() is not working within my AWS Lambda when executed. I receive no data back from my fetch and nothing in Cloudwatch. I think my issue is the multiple async/await/promises. I'm unsure how the multiple promises work. Can someone help refactor these functions? Thanks!
Handler:
export async function consumer(event, context) {
event.Records.forEach(async (record) => {
const body = JSON.parse(record.body)
api_url.searchParams.append("url", body.url)
await callPSI(api_url.href)
});
}
export const callPSI = async (url) => {
const url = "https://jsonmock.hackerrank.com/api/movies";
fetch(url).then(res => {
console.log("response: ", res)
return res.json();
}).then(data => {
console.log('data: ', data);
})
}