I’ve been trying to make these code works what I expected, but it doesn’t really works what I expected
import fetch from 'node-fetch';
const BASE_URL = 'https://estra-api.herokuapp.com/';
let EstraLoader = class Estra {
loadAPI() {
var data = '';
fetch(BASE_URL)
.then(function (response) {
return response.json();
})
.then(function (myJson) {
data = myJson;
return data["Version"];
});
}};
let EstraJS = new EstraLoader();
console.log(EstraJS.loadAPI());
The output always undefined, is there anything I can change from this codes that I made?
All I did want was the return data["Version"];
gives output by using console.log(EstraJS.loadAPI());