Ultimately, you can choose whatever library you prefer to use with your baseQuery, but it's important that you return the correct response format. If you haven't tried fetchBaseQuery yet, give it a chance!
RTK Query exports a utility called retry that you can wrap the baseQuery in your API definition with. It defaults to 5 attempts with a basic exponential backoff.
The default behavior would retry at these intervals:
600ms + random time
1200ms + random time
2400ms + random time
4800ms + random time
9600ms + random time
Retry every request 5 times by default
// maxRetries: 5 is the default, and can be omitted. Shown for documentation purposes.
In the event that you didn't want to retry on a specific endpoint, you can just set maxRetries: 0.
info
It is possible for a hook to return data and error at the same time. By default, RTK Query will keep whatever the last 'good' result was in data until it can be updated or garbage collected.
There are quite a few ways that you can manage your errors, and in some cases, you may want to show a generic toast notification for any async error. Being that RTK Query is built on top of Redux and Redux-Toolkit, you can easily add a middleware to your store for this purpose.
tip
Redux-Toolkit released matching utilities in v1.5 that we can leverage for a lot of custom behaviors.