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

192
Views
How to wait for a async function to resolve in JavaScript

I have something like :

    const isInvited = async (user) => {
        const res = await axios.get(url(`/api/invite/isInvited?target_user_id=${user.pk}`), {
            headers: {
                "auth-token": authToken,
            }
        });

        return res.data;

    }

    const searchPeoples = async e => {
        e.preventDefault();

        const query = e.target.querySelector("#query").value;

        setSearching(true);
        const res = await axios.get(url(`/api/user/search/?query=${query}`));
        const found = await res.data.map(async item => {
            const is_Invited = await isInvited(item);
            return { ...item, is_Invited }
        });

        setSearching(false);
        console.log(found)

        setFoundPeoples([]);

    };

But when I see the console, the value of found (var) equals to a Promise object, But I want to see the data of response that the isInvited function returns. I am working on a project but this problem is stopping me to complete my project. Please help me to fix this problem.

about 4 years ago · Juan Pablo Isaza
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!