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

174
Vistas
Loading data from two different models and combine them in React Js using hooks and axios

I am loading data from two different models (patients and diagnoses). I need to display patients' diagnoses, but in order, to do that, I need to pull patients.main_diagnoses to get the 'id' of diagnose, and then I need to find that id in diagnoses.

Calling the API to get patients and diagnoses. Also, I am trying to get the diagnosis data to render.

useEffect (async () => {
    try {
        response = await patientService.getDiagnosesList()    
        options = await response.map ((diagnose) => ({
                'value': diagnose.id, 
                'label': diagnose.name
            }))
        setDiagnoses(options)


        response = await patientService.getPatient(id)
        setPatient(response)
        setLoading(false)
    } 
    catch (error) {
        console.log(error)
    }
}, [])

After that I am trying to render the data in return ()

 <div>
            <ul>
                <li>Příjmení a jméno pacienta</li>
                <li>{patient.last_name} {patient.first_name}</li>
                <li>Rodné číslo pacienta</li>
                <li>{patient.birth_number}</li>
                <li>Diagnóza</li>
                <li>{patientDiagnose}</li>
                <li>Oddělení</li>
                <li>{patient.current_hospital_care?.department.description || patient.current_ambulance_care?.department.description }</li>
                <li>Ošetřující lékař</li>
                <li>No data</li>
                <li>Poznámka</li>
                <li>{patient.note || 'Žádné poznámky'}</li>
                <li>Žádost o konzulium</li>
                <li>Příjmení a jméno pacienta</li>                    
            </ul>
        </div>

Thank you for your help.

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