Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda