I'm trying to wait until image uploaded on firebase storage by using loader but it doesn't work fine
I wrote my code like this but I don't know where is my mistake and why alert show before uploading process.
private uploadPhoto(): void {
let loader = this.loadingCtrl.create({
content: ""
})
loader.present().then(_=>{
this.myPhotosRef.child(this.generateUUID()).child('myPhoto.JPEG')
.putString(this.myPhoto, 'base64', { contentType: 'image/JPEG' })
.then((savedPicture) => {
this.myPhotoURL = savedPicture.downloadURL;
this.afd.list('/Images/').push({
nID: this.appService.id,
url: this.myPhotoURL,
date: new Date().toISOString()
});
});
}).then(_=>{
alert("image uploaded and stored in database");
loader.dismiss();
})
}
I got the solution by adding "return" before "this.myPhotosRef.child..."