Reputation: 969
Is there any way to determine if a Axios request like the following received an answer and is done?
axios.get('/api')
.then(response => this.data = response.data);
Upvotes: 5
Views: 14473
Reputation: 276286
Yes, this is a promise and you can reference and then
it:
var req = axios.get('/api')
.then(response => this.data = response.data);
Now I want to react to it being done:
req.then(x => console.log("Done!"));
Or save that state outside:
var isReqDone = false;
req.then(x => isReqDone = true);
Upvotes: 3