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

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

#1


https://codepen.io/simongjetaj/pen/KXvrVM?editors=0010

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.


#2

Try this

  fetch(api).then(res => {
    res.json().then(data => {
      console.log(data)
    });
  });

#3

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

  fetch(api)
    .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
   
  });

#4

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