Reputation: 1638
I'm trying to get the baseURL from customApi.js
axios that is created using export default axios.create()
configuration.
customApi.js file
import axios from 'axios';
export default axios.create({
baseURL: 'http://123.123.123.123:5000'
});
I tried the following, but it console logs undefined
.
import api from 'customApi.js';
console.log(api.baseURL);
What is the correct way to get the base url in a custom configured axios?
Upvotes: 2
Views: 4178
Reputation: 178126
Here is how I found it.
const x = axios.create({
baseURL: 'http://123.123.123.123:5000'
});
// for (let o in x) console.log(o,x[o])
console.log(x.defaults.baseURL)
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
Upvotes: 7