loading...

re: Javascript Promise Chaining & Error Handling VIEW POST

FULL DISCUSSION
 

Nice post! For fetch requests, I prefer to check res.ok instead of using the error handler.

 

oh cool, we use axios which takes a validateStatus function parameter to determine whether the Promise should succeed or fail.

Though we do have some places in code when the API gives 200 but without any data (bad APIs). Hate having to write the error handler twice in this case to handle cases when the API returned a response or if it failed due to network error. Slowly getting those APIs upgraded to reflect the appropriate status.

Code of Conduct Report abuse