Skip to content
Advertisement

How to update this axios service for being able conditionally decide which API URL to use?

I have the following axis service:

JavaScript

I need conditionally pass isAdmin from outside for being able to switch the API URL here. How can be it achieved.

Advertisement

Answer

You can use multiple instances for each baseURL and call the instance by isAdmin condition. However, you can config the defaults that will be applied to every request.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement