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

104
Views
async request via jquery $.get()

When I am using the following code the output is undefined

const getData = async() => {
    $.get("foo", (data) => {
        return data;
    })
}

(async () => {

    const d = await getData();
    console.log(d);

})();

http://127.0.0.1:5000/foo site is a json file.

But If I am using the following code I get the json file.

(async () => {

    const getData = await $.get( "foo", (data) => {
        return data;
    });
    console.log(getData);

})();

Why the first one does not give the proper output?

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

0

It seems that you forgot a return in your function

const getData = async() => {
    return $.get("foo", (data) => {
        return data;
    })
}
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!