2👍
✅
Maybe just set the variable before and after the await
call?
this.IsUploading = true;
await fileUpload;
this.IsUploading = false;
1👍
Here are some cases, that you can use.
- I think this is the best and the most correct way, it’ll call your function only once, maybe, the problem is in another thing?
async submitForm() {
const FormBody = new FormData();
await fileUpload();
this.$axios.post('/api', FormBody)
}
- You can make set your value to true and wait until
fileUpload()
returns something:
async submitForm() {
const FormBody = new FormData();
this.IsUploading = true;
if (await fileUpload()) this.IsUploading = false;
this.$axios.post('/api', FormBody)
}
- Or just change it right away after getting respond from
fileUpload()
, as told Jack Bashford:
async submitForm() {
const FormBody = new FormData();
this.IsUploading = true;
await fileUpload();
this.IsUploading = false
this.$axios.post('/api', FormBody)
}
Source:stackexchange.com