Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda