Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!