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

132
Views
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 answers
Answer question

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