import axios from "axios"
import store from".. / store/index"
export function netlink (config) {
return new Promise ((resolve,reject) = > {
//axios
const instance = axios.create({
headers:{
"Content-Type": "application/json",
},
timeout: 5000,
baseURL: "http://192.168.1.240/api/",
method: "post",
});
// request
instance.interceptors.request.use(
config => {
//
return config;
},
error => {
return Promise.reject(error) // (catch)
}
)
// response
instance.interceptors.response.use(function (response) {
//
console.log(JSON.stringify(store.state) + "888888")
if(response.data.Status == 1){
}
return response;
}, function (error) {
//
return Promise.reject(error);
});
instance(config).then(res =>{
resolve(res);
}).catch(err => {
reject(err);
})
});
}
/ / encapsulates the calling interface getData
export function getData (url,data) {
return netlink({
url: url,
data: {
data: data,
token: localStorage.getItem("token")
},
})
}
/ / Server rendering call API
export function getDataDev (url,data) {
return netlink({
url: url,
data: {
data: data,
token: ""
},
})
}
here console.log (store) is shown as undefined, asking God to tell you how to get the value in vuex