Is it possible to change the baseURL after the api is created?
See original GitHub issueSomething like this:
this.api = create({
baseURL:'localhost:8999'
})
this.api.setBaseURL('somefancyapi.com');
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:14 (6 by maintainers)
Top Results From Across the Web
android - Retrofit - Change BaseUrl - Stack Overflow
I have a scenario where I have to call an API with the same base URL, e.g. www.myAPIĀ ...
Read more >Change BaseURL in OnBeforeRequestAdvanced - OutSystems
I see the log doing the replacement fine...but in the integrations tab (logging in ServiceCenter), it's calling the API with the original URL....
Read more >Retrofit 2 ā How to Change API Base Url at Runtime
With this setup you don't have a chance to change the API_BASE_URL constant at runtime. You've change it in the source code, compile...
Read more >API Server and Base Path - Swagger
In OpenAPI 3.0, you use the servers array to specify one or more base URLs for your API. servers replaces the host ,...
Read more >How can I change the existing base URL of Artifactory - JFrog
Navigate to Admin -> Configuration-> General Configuration-> General settings -> change Custom Base URL to a new url. Option 2 (If you are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Axios allows you, but we should definitely have a way. In fact, exactly like you suggest. š
To change it, youāve got a few options.
api
object with the baseURL being what you want.api.axiosInstance.setBaseURI('xxx')
to change the instance (this is the thing Iāll make easier to do that was suggested at the start of this ticket).api.getThing('myApiCall', {x: 1}, { baseURI: 'swappyswap.com' })
.It sounds like your situation is you connect to an API, then part way through the āsessionā, you change the APIās sub-domain.
Iād do bullet point 1, personally, unless youāve got a bunch of āstateā packed into the API object.