axiosinstance global notification
Are there any examples of setting up global notifications when you use the axiosinstance directly
2 Replies
Hi @Todilo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the knowledge sources do not contain a direct example of setting up global notifications specifically when using the axiosInstance directly in Refine. However, there are related discussions and best practices:
- You can create a custom axiosInstance and pass it to your dataProvider, which is a common pattern for handling authentication headers globally. This is shown in several examples, but not specifically for global notifications on axios errors or responses. For example, you can set up an axiosInstance and use it with your dataProvider as follows:
GitHub Issue: How to send headers in api request?
- For error handling, it is mentioned that you can use axios interceptors to handle errors globally, which could include triggering notifications. However, there is no explicit code example in the sources for integrating Refine's notification system (like useNotification) directly within axios interceptors.
- There is a user request for a "single place to handle all notifications," similar to how errors can be handled globally with axios interceptors, but currently, success notifications must be set in each hook or resource. This suggests that while error handling globally via axios is possible, global success notifications are not yet supported in a centralized way in Refine, and you would need to use the successNotification and errorNotification props in each hook or form for now GitHub Issue: Single place to handle all notifications.
In summary, while you can use axios interceptors for global error handling (and potentially trigger notifications there), there is no official example or built-in Refine feature for global notifications tied directly to axiosInstance in the provided knowledge sources. For notifications within Refine, you should use the notificationProvider and the successNotification/errorNotification props in your hooks and forms.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@207945811592478720> Kapa.ai is still learning and improving, please let me know how I did by reacting below.