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

160
Views
Reaccionar: JS no almacena objetos en global

Estoy tratando de insertar un objeto (usuario) en un global para poder consultarlo sin tener que hacer numerosas llamadas api cuando sea necesario.

Los datos se obtienen del servicio bien, sin embargo, no se almacenan

El código:

 useEffect(()=>{ // this needs to be here because the user doesnt exist on first render if (user){ fetch (`${window.ipAddress.ip}/User/getByEmail`,{ method: "POST", headers:{'Content-Type':'application/json'}, body: JSON.stringify({ email: user.email }) }) .then(res=>res.json()) .catch(error =>{ setErrorVal(true); console.log("error: " + error); }) .then((result)=>{ console.log(result) // this prints appropriately window.BackendUser = { result } // this isnt being set for some reason setExecutedFetch(true); }) } },[isAuthenticated])
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No puede escribir corchetes alrededor de su resultado, el corchete es sintaxis JSX.

 window.BackendUser = result
about 4 years ago · Juan Pablo Isaza Report
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!