What is the purpose of creating an instance by axios? can you not use it?

axios.create ({baseURL: ajaxUrl,timeout: 3000dint withcredentials: true}) what is the role of creating an instance? sharp-sharp-sharp problem description
introduce axios, and then request axios.get ("url") .then (res= > {}) on the page. What role does the created instance play here

Jul.06,2021

the instance axios is exported by default, and you usually only need to use this axios .

but sometimes you need to create multiple instances, for example, you need to access multiple service addresses, and the structure of these service requests and responses are completely different, so you can create different instances by axios.create .

for example, axios1 uses http status codes to determine whether the response is normal, while axios2 is a status code defined by the server itself, or their request headers are different and support content-type , then I can write interceptors for axios1 and axios2 separately.

Menu