
Learn JavaScript api handling with fetch, axios, and error handling. API handling refers to making HTTP requests to a server to fetch or send data....
For further actions, you may consider blocking this person and/or reporting abuse
I'm on a quest against
if (!response.ok) throw...
.The Ugly Truth: All Popular fetch() Wrappers Do It Wrong
Discover the reality behind axios, ky and popular data-fetching NPM packages and how to replace them.
Try catch is an important wrapper as it avoids the termination of the app if there is an exception during data fetching, best example would be data fetching in next js, If you don't use try catch and an exception occurs, your webpage will crash
I'm not against generic try..catch. I'm against throwing an error when a non-OK response is received via fetch() because then you are forced to write an extra try..catch.
Yeah, that is just an example, in a real world project, we will be adding an error state and a UI for that exception.
I thought this article was about going pro! Anyway, what about retry logic, have you seen that implemented in the real world?
@z2lai are you asking the author or me? Apologies. The notification showed up in my feed. The author, right?
This article is about API handling only in multiple ways.
There are too many examples and concepts that can't be covered in 1 blog.
This article is focusing on how we could handle the api like fetch method for beginners, axios method and react useEffect for intermediate and React query for pro
It's not possible to go in depth about these covering all the concepts in detail in a single article.
You could refer the official documentation for these concepts to learn more about other implementations like pagination, infinite scrolling, retries, dynamic data fetching, refetch on operation, etc.
Incredibly helpful, thank you!
Nice, this is a great overview. Pretty sure I have used each method in different projects.
thanks for the lovely introduction..