admin管理员组文章数量:1404563
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?
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?
Share Improve this question asked May 28, 2020 at 11:51 kaizenkaizen 1,6384 gold badges31 silver badges53 bronze badges1 Answer
Reset to default 7Here 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./ajax/libs/axios/0.19.2/axios.min.js"></script>
本文标签: javascriptHow to Get the BaseURL from axioscreate(baseURL)Stack Overflow
版权声明:本文标题:javascript - How to Get the BaseURL from axios.create({baseURL})? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744825234a2627020.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论