Why does this.XXX have to wait a while to get the minor problems encountered in vue that this.XXX can"t get directly?
I am now calling two interfaces, such as An and B.
I can only call Interface B after An ends. (because API A returns data, I need to use it to get Interface B)
my code is like this
let promise = new Promise(function(resolve, reject) {
//Access Token
axios.get("api/token?grant_type=client_credential&appid=appid&secret=secret")
.then(function(response) {
_this.access_token=response.data.access_token;
console.log(_this.access_token);
})
.catch(function(error) {
// error
console.log(error);
});
resolve();
});
promise.then(function() {
//jsapi_ticket
console.log(_this.access_token);
axios.get("api/ticket/getticket?access_token="+_this.access_token+"&type=jsapi")
.then(function(response) {
// success
console.log(response);
})
.catch(function(error) {
// error
console.log(error);
});
});
After the An interface is completed, the resolve B interface is thrown for access, but my _ this.access_token is not worth it. I have to add an one-time timer to it to delay it. Why?