在以下方面有两种选择:
axios
-
custom instance
// Create an instance using the config defaults provided by the library
// At this point the timeout config value is `0` as is the default for the library
const instance = axios.create();
// set a default baseURL for this particular instance
instance.defaults.baseURL= 'http://new-root.com';
-
使用自定义
baseURL
使用
request config
:
axios.get('my/url', { baseURL: 'http://new-root.com' })
轴心
每个“端点”的实例-
HTTP.userApi
将是实例和
HTTP.productApi
祝你好运!