- Make XMLHttpRequests from the browser
- NO CACHING
- Make http requests from node.js
- Supports the Promise API
- Intercept request and response, Transform request and response data and Cancel requests
- Automatic transforms for JSON data
- REPO, https://stackblitz.com/edit/react-axios-not-cached
React Query(caching) + fetch/axios
- React Query is one of the best libraries for managing server state.
- React Query is specifically designed to manage any asynchronous state that you get from outside of your app: server-state, API state that is not local client state.
- REPO, https://stackblitz.com/edit/react-query-fetch
SWR(caching) + fetch/axios
- React Hooks library for data fetching
- SWR works with three main steps: first, it returns the data from the cache (the stale part), then sends the fetch request (the revalidate part), and finally comes with the up-to-date data
- SWR under the hood uses the Fetch API to request data from the server — it’s kind of a layer built on top of it. However, it has some nice features such as caching, pagination, scroll position recovery, dependent fetching, etc, and to be precise a certain level of reactivity out of the box that Axios or Fetch do not have. Hence increases the performance of our app.
- REPO, https://stackblitz.com/edit/react-swr-cache-fetch
Read these articles too for more clarity,
Don’t forget to follow me on medium for more updates.
If this was useful, please click the clap 👏 button down below a few times to show your support!