We use the Fetch API (built into browsers) to fetch data.
The fetch
function is quite simple to use. It returns
a Promise that resolves to
the response of the request.
We use React Query for state management. State management in React is notoriously hard to get 100% right and safe, which is why using a library such as RQ is a good idea. It saves us from a lot of potential common bugs and headaches with managing state all by ourselves.
If you're not convinced, read this great article by TkDodo on Why You
Want Need React Query. It explores a lot of common pitfalls/bugs. At the time of me writing this, these
pitfalls/bugs are found absolutely everywhere we do data fetching in Samfundet4. Hopefully over time, we will replace
these instances with safe state management using RQ.
Please check out the RQ docs Quick Start.