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

140
Vistas
NETWORK ERROR does not get resolved by axios

I'm sending a request to a backend THAT IS OFFLINE using axios

const backendClient = axios.create({
  baseURL : env
});

The API gets called

export const createExpensesRecord = async (createExpenseRecordCmd) => {
    try {
        await backendClient.post("/api/accounting/expenses", createExpenseRecordCmd)
        return true
    } catch(error) {
        return false
    }
}

The error code should trigger, as the backend is not reachable with Error: Network Error.

function submitAccountingRecord() {
        if(formDataValid()) {
            
            if(createExpensesRecord(cmd)) {
                console.log("SUCCESS")
            } else {
                console.log("FAILED")
            }

            ...
        }
    }

No matter what I do, I always receive SUCCESS. Played around with it for over an hour and couldn't get consistant behaviour. What am I doing wrong?

Be aware that I tried multiple approaches, maybe we can stick to this one than suggestion different options to solve it. It's the most straight forward approach I could think of

---- UPDATE

await function submitAccountingRecord() {
        if(formDataValid()) {
            
            if(await createExpensesRecord(cmd)) {
                console.log("SUCCESS")
            } else {
                console.log("FAILED")
            }

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

0

Server being offline is not an error really. In fact, you shouldn't rely on any HTTP tool (be it axios or native fetch API). Read this thread to learn more.

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