I have the following code:
function fetchDemo() {
var result;
fetch(countriesUrl).then(function(response) {
return response.json();
}).then(function(json) {
result = json;
});
return result;
}
console.log(fetchDemo());
console.log(fetchDemo()) the following returns undefined. I need to use that value inside another function.