DEV Community

Discussion on: Javascript Promise Chaining & Error Handling

Collapse
 
azizhk110 profile image
Aziz Khambati

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.