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

214
Vistas
Why is my variable not accessible in the fetch?

My props of my export function : projectId and identityPseudonymGroup are accessible in the use effect with the log console, i.e. I have results but not in the fetch body. However they are global variables. Even with the use state, it doesn't work. The error is "Uncaught (in promise) TypeError : Failed to fetch"

const Export = ({identityPseudonymGroup, projectId}) => {
    useEffect(() => {
        console.log("id group" + identityPseudonymGroup)
        console.log("id project" + projectId)


         fetch("http://localhost:4000/api/observations/pacs/aggregation", {
                method: 'POST',
                headers: {
                    'Access-Control-Allow-Origin': '*',
                    'Content-type': 'application/json',
                    'Accept': 'application/json',
                    'Authorization': `Bearer ${keycloak.token}`,
                },
                body: JSON.stringify({
                    'project_id': `${projectId}`,
                    'identity_pseudonym_group': `${identityPseudonymGroup}`
                })

            })
                .then(response => response.json())
                .then(response => {
                    var data = response;
                    setData(response)
                    Object.keys(response).map((key, index) => setChoiceStudy(array => [... array, key])) // select all studies for the filter

                    // Select all modalities and series
                    Object.keys(response)
                                             .map((key, index) => (
                                                response[key].map((value) => {
                                                    setChoiceModality(array => [... array, value['modality']])
                                                    setChoiceSeriesName(array => [... array, value['series']])
                                                })));

                })

    }, []);
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