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

110
Vistas
How to check if post request was succesfull or no in Redux?

I have Action in Redux. Where I make request to backEnd to do something. And I need to check if Post request whichIi made was successful or no.

export const changeEmployee = (id, status) => {
  return async (dispatch, getState) => {
    try {
      dispatch(changeEmployeeRequest());
        await adminAPI.changeEmployee(id, status);
        dispatch(updateUserWithRolesSuccess(usersWithRoles))
      } catch (error) {
      dispatch(updateUserWithRolesFailure());
    }
  }
}

Unfortunately I do not receive any data from this request. So I cannot check it works. But I was curious is there are any ways to get status of request. As I can see this status in Chrome's Network tab.

And this is my API, which is in separate APIs page.

export const changeEmployee = (id, status) => API.post(`${UPDATE_EMPLOYEE}`, {id, status});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should be able to store the response as a value within your function and then check the status of that

const res = await adminAPI.changeEmployee(id, status)
if(res.status === 200) {...}

As said above, it looks like you are using axios which should throw an error and what will be handled in the catch block. If you have got different outcomes for different errors you can add logic based on the error status code, similar to this:

catch (err) {
   switch (err.response.status) {
      case 401:
         ...
         break
      case 400:
         ...
         break
      default:
         ...
         break
  }
}
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