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

464
Vistas
Exception while consuming REST API from React JS

I have created a REST Endpoint in python application & it works fine when called from the browser. However, when I am trying to consume it in React JS application, it gives error on console.

I tried various ways for calling it as below.

  1. Plain Old Javascript
        var request = new XMLHttpRequest();
        request.open("GET", "http://127.0.0.1:5000/countries", true);
        request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
        request.send(data);

Error in console: On last line of above code, getting :

"Failed to load resource: net::ERR_FAILED"

  1. Fetch method in REACT
fetch(apiUrl)
            .then((response) => response.json())
            .then((data) => console.log("This is your data", data));

Error in console: On last line of above code, getting :

"Failed to load resource: net::ERR_FAILED"

"Uncaught (in promise) TypeError: Failed to fetch

  1. Axios :
axios.get("http://127.0.0.1:5000/countries")
            .then(res => {
                const responseData = res.data;
                console.log("responseData is : ", responseData);
            });

Error in console :

Uncaught(in promise). -> AxiosError -> Network error

Axios Error snapshot

Is there any issue with network/proxy settings or any library?

I need to make GET requests first, then POST requests as well. Please suggest with an example.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

have you tried localhost instead of 127.0.0.1?

about 4 years ago · Juan Pablo Isaza Denunciar
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