const userfetched =[];
fetch('https://jsonplaceholder.typicode.com/users').then(response=> response.json()).then(user=>userfetched.push(user));
console.log(userfetched)
here it outputs empty array.
but if i use the following code :
const userfetched =[];
fetch('https://jsonplaceholder.typicode.com/users').then(response=> response.json()).then(user=>console.log(user));
console.log('end')
it outputs end then the array values.
How do i wait till the fetch response is filled and iterate over it?