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

123
Vistas
i want use the result of the URL in a variable in JS

how i can use the result of this link in variable javascript :

https://aa.real-tv1.com/testtt.php?action=reseller_mapdash1

let url = 'https://aa.real-tv1.com/testtt.php?action=reseller_mapdash1';

var myVariable;

fetch(url).then(res => res.json()).then((out) => {

   myVariable = out;
   
   console.log([myVariable]);
   
}).catch(err => { throw err });

console.log([myVariable]);

so i know where is the problem now , when i use the variable 'myVariable'

outside a function i have Variable undefined

so how i can use the variabla outside a function ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Well, you have done most of the job, you simply assign the result "out" to a variable like so:

let url = 'https://aa.real-tv1.com/testtt.php?action=reseller_mapdash1';
let myVariable;

fetch(url)
    .then(res => res.json())
    .then((out) => {
        myVariable = out; // here you assign to your variable
    })
    .catch(err => { throw err });
about 4 years ago · Juan Pablo Isaza Denunciar
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