i have a result variable where i am trying to populate/assign array using Fetch. It keeps being undefined, also the function keeps returning promises. I can console it but the result is always undefined.
const url = 'https://www.w3schools.com/angular/customers.php';
let result;
function getData(){
return fetch(url)
.then(response => response.json())
.then(data => result = data.records)
}
getData();
let list = getData();
console.log(result) // undefined
console.log(list) // Promise {}