Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda