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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.