Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
Javascript NodeJS - Can we make a local function variable becomes a global variables inside of class?

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());

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!