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

184
Views
la solicitud de red de lanzamiento de búsqueda falló en React native + expo

Actualmente estoy tratando de enviar una solicitud a una API de Flask desde mi aplicación nativa de reacción de Android. La cuestión es que la fetch siempre arroja el mismo error, Network request failed . He estado buscando, pero ninguna de las respuestas que he encontrado se aplica. Me aseguré de que la solicitud se dirigiera a la dirección y el puerto correctos, y todo parece correcto. Intenté hacer la misma solicitud con Postman y funciona bien, así que sé que el servidor está funcionando.

Aquí está mi código:

 function apiRequest(path, method, body = "") { const url = path; console.log("going"); console.log(url); fetch(url, { method: method, headers: { "Cache-control": "no-cache", }, body: body, }) .then((response) => { if (response.ok) { if (response.status == 204) { return true; } return response.json(); } throw new Error(`${response.status}: ${response.body}`); }) .then((json) => { console.log(json); return json; }) .catch((error) => { console.log("ERRORED:"); console.error(error); }); }
 var response = apiRequest( "http://192.168.2.244:5000/driver/register", "POST", JSON.stringify({ name: name, email: email, password: password, }) ); console.log(`RES: ${response}`);

Cualquier ayuda sería muy apreciada.

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

0

Debería intentar agregar 'Content-Type' en los encabezados:

 headers: { Accept: 'application/json', 'Content-Type': 'application/json' // I added this line }
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!