I want to use Fetch API but I don' t really understand it's mechanism.
I have an <h1> in my HTML and I want to assign the result of my fetch with this code:
const weather = "http://api.apixu.com/v1/current.json?key=cba287f271e44f88a60143926172803&q=Paris";
const array = [];
fetch(weather)
.then(blob => blob.json())
.then(data => {
  array.push(data.current.humidity)
  console.log(array[0])
      }
);
 document.querySelector('h1').innerHTML = array[0]; 
I have the result with the console.log but the <h1> returns "undefined". Can you explain why?
 
     
    