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

107
Views
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 answers
Answer question

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 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!