37
rated 0 times
[
44]
[
7]
/ answers: 1 / hits: 17527
/ 8 Years ago, tue, september 20, 2016, 12:00:00
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.
More From » javascript