3π
β
In your case, you can do show loading
before calling axios,and hide loading
in then
funciton, caused by axios return a promise.
example:
let loading = true
axios.get('/user/12345').then((response) => {
loading = false;
})
If you use async
syntax, will be more easy:
async funciton fetchSth() {
let loading = true;
await axios.get('/user/12345');
loading = false;
}
π€Mervyn
Source:stackexchange.com