Local Weather, problem with fetch() and spread operator [CLOSED]


Hello Guys,

I got stuck to this problem.
The idea is to push the data from the api to an array so I will get the data and interact with HTML more easily but it seems to not work. Could someone help me?

Thanks in advance, Simon.

Try this

  fetch(api).then(res => {
    res.json().then(data => {
1 Like

Similar to what @michal9909 used, but with your chosen variable names:

    .then(blob => blob.json())
    .then(data => {
    // put your code to work with the data JSON object here
    // no need to push to an array, because it is already an object
1 Like

Thank you very much @michal9909 and @RandellDawson. :+1: