Access axios instance used to create data provider
Is there a way to access the axios instance that I used in the creation of my data provider elsewhere in the code? I need to manually submit an axios request, and I want access to the interceptors I setup when creating the dataProvider that's registered to <Refine>.
2 Replies
Hi @Hypnotic Meat. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, you can access the axios instance used to create your data provider elsewhere in your code. Here's how you can do it:
1. When creating your data provider, export the axios instance:
2. Then, in your components or other parts of your code where you need to make manual axios requests, you can import and use this axios instance:
This approach is demonstrated in the Simple REST data provider documentation, where they show how to create and use a custom axios instance:
By exporting and reusing the same axios instance, you ensure that all your requests, whether they go through the data provider or are made manually, use the same configuration and interceptors.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@224018850419572736> Kapa.ai is still learning and improving, please let me know how I did by reacting below.