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

94
Vistas
Reactjs state doesn't updating after async await API call

I am a beginner in React. I have a setState from my async await function which calls an API. after calling the API, there are some issues happen since my state doesn't update immediately. How can I await my setState funcion so that it changes when the latest data was pulled?

Here is my whole function.

const getTimeLogsFromAPI = async () => {        
        const person_id = props.profile.basic_information.primary_information.id;
        const uuid = props.profile.basic_information.primary_information.uuid_qrcode;
        const new_format_date = dateFormatter(new Date(state.selectedDate));
        const response = await fetch(`${getDjangoApiHost()}/api/jobnet_app/pass_check/${uuid}/?specific_month=${new_format_date}&person_id=${person_id}`);
        const dataTimeLogs = await response.json();
        if (dataTimeLogs) {
            await setTimeLogs(dataTimeLogs)            
        }
        if (timeLogs) {
            await setShowDTR(true);
        }
    }  
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