DEV Community

Discussion on: Ways of Getting Data from API in React

Collapse
 
insuusvenerati profile image
Sean

Is the try catch useful for an async api call? If the promise rejects, the catch will not be triggered.

Collapse
 
zer0 profile image
zer0

There is actually situations where using axios, “try/catch” & async/await can cause unwanted behaviour.
At least for me it did.
E.g. when using interceptors a failed request might not end up in catch.

Collapse
 
insuusvenerati profile image
Sean

Nevermind, just read it does actually throw :D