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

266
Views
How can i use JSON data out of callback function

Hi I'm trying to get JSON data from a JSON file. I got it on my JS code but i cant use it out of the callback function. I want to use the data anywhere in my code. I want to pass the data to a variable

My code for getting JSON data is :

async function load() {
    let url = 'sorular.json';
    let obj;
    obj = await (await fetch(url)).json();
    return obj
}
    load().then(res=>{console.log(res)})
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

in the THEN, simply call a separate function where res is passed as argument.

function processJSON(data){
  //run your other functions here
}

load().then(res=>{processJSON(res)})
about 4 years ago · Santiago Trujillo 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!