I am learning backend development can you help me to hit an api? I tried doing something like this but it's not hitting the API also it's not logging "Making API call" I tried to console log expirationDate, token, and email and they three logs correctly but still it's not hitting the API and not logging Making API call What's wrong with my code and how can I fix it?
Also No error In the console
Also I am using node-schedule and the value of expirationDate, token, and email look like this
2023-03-30T01:48:46.962Z dsvicPH1SSOCdHWpxrMrvF:APA91bFYXRKOsa2F_JTYkEOLiPM32o1NoWDi2fgE_vssum3csYJt_kLRZK9BfARoogQ7Q3xxWeFREo3J4ms_MEZYPGo_bEWlVZzG-kEJC_juw8fvw8J3OXiJNE4w0owjiAuIHWOcRhsR idsdsdd@gmail.com
The Token is a FCM token What is FCM token in Firebase?
function scheduleApiCall(expirationDate, token, email) {
console.log(expirationDate, token, email)
// Schedule the API call to be made at the specified date and time
const job = schedule.scheduleJob(expirationDate, async function () {
// This function will run at the specified date and time
// Make the API call here
console.log('Making API call');
try {
const response = await axios.post(
'http://localhost:3000/getnoti',
{
title: 'SERVER NOTIFICATION',
body: 'I am coming from server',
token: token
},
{
headers: {
'Content-Type': 'application/json'
}
}
);
console.log(response);
} catch (error) {
console.error(error);
}
});
// job.cancel();
}