Setting baseURL in default configuration
See original GitHub issueIn some cases my app requires different defaults from the standard ones, and I’ve been dealing with this by putting something like this in the app’s entry point:
let axiosDefaults = require('axios/lib/defaults');
axiosDefaults.baseURL = 'http://somesite.com';
My tests are run in Node and I want to override the baseURL
so that axios will work with Nock even with relative URLs, but the code above doesn’t work. Would it be reasonable to add this parameter to the defaultConfig when instantiating Axios? Or is there a better way I should be doing this? I have an example of what I mean here.
Issue Analytics
- State:
- Created 8 years ago
- Comments:27 (9 by maintainers)
Top Results From Across the Web
Config Defaults | Axios Docs
Set config defaults when creating the instance const instance = axios.create({ baseURL: 'https://api.example.com' }); // Alter defaults after instance has ...
Read more >Axios default configuration - how to set baseUrl and header ...
I am trying to set configure the axios with baseUrl and headers for each call. Is the following code correct? If I set...
Read more >Configuring the base URL | Administering Jira applications ...
To configure the base URL: In the upper-right corner of the screen, select Administration > System. In the sidebar, select General ...
Read more >Cleanly Setting Axios Base URL - YouTube
Want more? Explore the library at https://www.codecourse.com Official site … Show more. Show more. Key moments. View all. App Setup.
Read more >38. Add Axios Default configuration like headers, base URL
In this video we will see how to add axios default configuration like headers, baseurl - Vue 3If you like my video, please...
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
@nathanharper One solution is to create a small module like this:
and then use this new module in your code instead of requiring
axios
directly:never mind! I realize I’m using the wrong property
baseUrl
insteadbaseURL