DEV Community

Discussion on: Making API calls in React using Redux-Thunk

Collapse
 
rajatpc profile image
rajatpc

I am here to get to know how to handle the errors, but bad luck you didn't cover up that part, I am hitting the API and got this object as an error in the http response->

error_code: 343
messsage: "Already accepted offer"
status: 0
Enter fullscreen mode Exit fullscreen mode

For normal response, I check everytime if status === 1 then that means I am having positive response, but in case of status === 0 that means some error coming from the server side but i am unable to print this message bcz it directly goes to the catch block and there i am getting simple http default error.
Do you have any idea how can I show this error message ?

Collapse
 
muhammadawaisshaikh profile image
Muhammad Awais

You missing something the boilerplate is tested and verified after each and every commit. So yeah

Collapse
 
muhammadawaisshaikh profile image
Muhammad Awais

You have take that error from catch block and store in your component state and do render in the Error section, also you can use the Reusable toast service to show the error from catch block, so there are multiple solutions you have to manage in terms of your need. Thanks