I added it like this. No, the request will not be executed.
service.interceptors.request.use(config => {
if (getToken()) {
config.headers["token"] = getToken() // token-- ["X-Token"]key
} else {
console.log("token")
}
const role = store.state.permission.roleList.find(role => role.url === config.url && role.confirmFlag === _const.YES)
console.log(role)
if (true) {
MessageBox("?", "", {
confirmButtonText: "",
cancelButtonText: "",
type: "warning"
}).then(() => {
config.headers["confirmUser"] = "wcsconfirmuser"
config.headers["confirmPwd"] = "123456"
// Do something before request is sent
return config
})
} else {
return config
}
}, error => {
// Do something with request error
console.log(error) // for debug
Promise.reject(error)
})