确定Axios请求是否已完成

时间:2017-07-08 22:29:29

标签: json vue.js axios

有没有办法确定像以下这样的Axios请求是否收到答案并且已完成?

axios.get('/api')
.then(response => this.data = response.data);

1 个答案:

答案 0 :(得分:1)

是的,这是一个承诺,您可以参考并then

var req = axios.get('/api')
               .then(response => this.data = response.data);

现在我想对它做出反应:

req.then(x => console.log("Done!"));

或者将该州保存在外面:

var isReqDone = false;
req.then(x => isReqDone = true);
相关问题