I have the following script:
async function getJobs () {
const response = await fetch('https://redhat.jobs/jobs/feed/json');
json = await response.json();
console.log("inside getJobs fuction " + json);
}
jobs = getJobs();
console.log("outside getJobs function" + jobs);
The first console.log displays the json response as I would expect. However, with the 2nd log I see outside getJobs function[object Promise]
in the console.
I think what is happening here is that I need to wait for getJobs to run/complete before assigning the results to the jobs
variable? Or is my approach this entirely wrong to begin with.
Just to give more context, I want getJobs to once, then I want to do stuff with the jobs array in the app.