I am trying to save the json response to the jsondata variable for use in other functions. But it is saying it is undefined.
let jsondata;
fetch(
`https://yahoo-finance15.p.rapidapi.com/api/yahoo/op/option/AMD`,
{
method: 'GET',
headers: {
'x-rapidapi-host': 'yahoo-finance15.p.rapidapi.com',
'x-rapidapi-key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
}
)
.then(
function (u) { return u.json(); }
).then(
function (json) {
jsondata = json;
}
)
console.log(jsondata)