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

124
Views
quiero usar el resultado de la URL en una variable en JS

cómo puedo usar el resultado de este enlace en javascript variable:

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

entonces sé dónde está el problema ahora, cuando uso la variable 'myVariable'

fuera de una función tengo Variable indefinida

Entonces, ¿cómo puedo usar la variable fuera de una función?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Bueno, ha hecho la mayor parte del trabajo, simplemente asigna el resultado "fuera" a una variable como esta:

 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 Report
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!