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

462
Views
La solicitud del cartero funciona, pero mi solicitud React no. donde esta mi error

Estoy haciendo una pila completa básica para hacer la aplicación. Hice backend con Java Spring. Cuando pruebo mi backend con Postman, funciona bien, pero cuando envío la misma solicitud con React fetch, ¡no funciona! Supongo que mi búsqueda es incorrecta, pero no puedo entender.

ingrese la descripción de la imagen aquí

 function register(){ fetch('http://localhost:8080/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify( { 'userName' : 'Pala', 'password' : 'sibop', } ) } ).then( res => { console.log("Result: " + res) } ).catch( err => { console.log("Erorororor: " + err) } )} function Home() { return ( <div> <h1>To Do!</h1> <form> <div id="signupArea"> <h2>Name</h2> <input id="userName"/> <h2>Password</h2> <input id="password" type="password"/> <button onClick={register}>SIGN UP</button> <button>LOGIN</button> </div> </form> </div> )}export default Home

ingrese la descripción de la imagen aquí

¿Cuál es mi problema?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Agregué "proxy": "http://localhost:8080" a package.json y cambié la URL de búsqueda a "/auth/register" y ahora funciona, ¡gracias!

about 4 years ago · Juan Pablo Isaza Report

0

Tienes que configurar el proxy, tienes un error CORS.

si está utilizando crear-reaccionar-aplicación.

https://create-react-app.dev/docs/proxying-api-requests-in-development/

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!