I am using the CronJob API to schedule Cron Jobs using google cloud functions. This is the code for creating the job.
var options = {
'method': 'PUT',
'url': 'https://api.cron-job.org/jobs',
'headers': {
'Content-Type': 'application/json',
'Authorization': `Bearer ${BEARERID}`
},
body: JSON.stringify({
"job": {
"url": url,
"enabled": true,
"saveResponses": true,
"schedule": {
"timezone": defaultTimezone,
"hours": [
hour
],
"mdays": [
day
],
"minutes": [
minute
],
"months": [
month
],
"wdays": [
-1
]
}
}
})
};
request(options, function (error: any, response: any) {
var jobID = response.body[`jobId`];
console.log(`job id is ${jobID}`);
console.log(`this is the body ${response.body}`);
});
This request returns a map in the body which contains the cron Job ID and it’s in the format
{"jobId":3978075}
I need to access the Job ID, but nothing i try is working. Nothing at all, and i am super frustrated.
THINGS IVE TRIED
var jobID = Object(response.body)["jobID"]
var jobID = response.body["jobID"]
var jobID = response.body.jobID
Nothing works. Please help.