Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda