Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

axios可以修改默认baseUrl吗?或者有什么别的方案

需求就是当默认的host访问失败之后,需要换一个host,
我重新设置了axios.defaults.baseURL = 'http://baidu.com',
但是没生效,还是用的默认的


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
axios.interceptors.request.use((config) => {
    config.baseURL = newUrl
})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...