Vue encapsulates axios Cannot read property 'interceptors' of undefined

vue-cli
import axios from "axios"
import QS from" qs";

axios.defaults.timeout = 5000;
axios.defaults.headers.post ["Content-Type"] =" application/json";
axios.defaults.baseURL =" http:// address ";

/ / request interceptor

axios.instance.interceptors.request.use (
config = > {

)
console.log(config)
return config

},
error = > {

return Promise.reject(error);

}
)
/ / respone interceptor
axios.instance.interceptors.response.use (
response = > {

)
const resp = response.data
if (response.status === 200) {
  return resp
}
return resp

},
error = > {

console.log("err" + error)
return Promise.reject(error)

}
)

/ * *

  • Encapsulation get method
  • @ param url
  • @ param data
  • @ returns {Promise}

* /

export function fetch (url,params= {}) {
return new Promise ((resolve,reject) = > {

axios.get(url,{
  params:params
})
.then(response => {
  resolve(response.data);
})
.catch(err => {
  reject(err)
})

})
}

/ * *

  • encapsulate the post request
  • @ param url
  • @ param data
  • @ returns {Promise}

* /

export function post (url, params) {
return new Promise ((resolve, reject) = > {
axios.post (url, QS.stringify (params))
.then (res = > {

)
resolve(res.data);  

})
.catch (err = > {

)
reject(err.data)  

})
});
}
then
import {post,fetch} from". / api/http.js"
/ / define the global variable
Vue.prototype.$post=post;
Vue.prototype.$fetch=fetch;

in main.js.

wrong Cannot read property "interceptors" of undefined
Why? by the way, what does @ param mean when the boss encapsulates it? thank you

Jun.07,2022

change axios.instance to axios
@ param is an annotation that can be ignored unless there are code specification restrictions.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c68b-2c324.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c68b-2c324.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?