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

141
Views
how to push return value from onload function to global variable
var myids = '';

function passid(){
    onload = function () {
        uidt = tempid.ssid; // some value getting from API
    }
}

passid();
console.log(myids);

Can Anyone help me with this, How to push uitd to var myids so I can be use wherever I want.

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

0

Your API request is definitely asynchronous, so you can use the promises via async await if you are inside an asynchronous function or then and catche if you are outside an asynchronous function

var mydata = '';

async function apiReq(){
  
  return await fetch('https://jsonplaceholder.typicode.com/todos/1').then(response=>response.json()).then(response=>{
    mydata = response
    console.log("test");
    console.log(mydata);
  
  })
  


}


apiReq().then(response => {
  console.log("request is ok")
  console.log(mydata);

});

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!