I am facing an issue with my Netlify function that is scheduled to run every minute using the @netlify/functions package. The function makes API calls and logs the response, but I cannot see any output from the console.log statement in the Netlify function logs.
Below is the code for my function:
import { Handler, HandlerEvent, HandlerContext, schedule } from "@netlify/functions";
import { dbIndex } from "src/app/dbIndex";
import { RestAPIService } from "src/service/RestAPI.service";
const getData: Handler = async (event: HandlerEvent, context: HandlerContext) => {
console.log("Received event:", event);
try {
const responses = [];
for (let i = 0; i < dbIndex.length; i++) {
const response = await RestAPIService.fetchTransactions({
id: dbIndex[i].id,
merch: dbIndex[i].merch,
date: dbIndex[i].date,
});
console.log("response->>: ", response.data);
responses.push(response.data);
}
return {
statusCode: 200,
}
} catch (e) {
return {
statusCode: 500,
message: e
}
}
};
const handler = schedule("* * * * *", getData);
export { handler };
When I run this function locally, everything works fine and I can see logs up until
console.log("Received event:", event);
. However, when deployed on Netlify, the logs are not displaying as expected.
I have tried various troubleshooting steps, such as checking the deployment status on Netlify, ensuring correct import values, modifying the console.log statement, and reviewing function execution logs for error messages. Unfortunately, none of these steps have resolved the issue. Can you please suggest what might be causing this problem and how it can be fixed?