I want to get downloadURL from this function. But, It doesn't wait to get it. So this function does not return downloadURL. How can I get it??
uploadProfileImage = async (uid, file) => {
        let userRef = this.str.ref(`${uid}`).child(`images/avatar.png`);
        const uploadTask = userRef.put(file);
        uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, snapshot => {
            let progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
            console.log('Upload is ' + progress + '% done');
            switch (snapshot.state) {
                case firebase.storage.TaskState.PAUSED:
                    console.log('Upload is paused');
                    break;
                case firebase.storage.TaskState.RUNNING:
                    console.log('Upload is running');
                    break;
                default:
            }
        }, error => {
            console.log('[Error] ', error);
        }, async () => {
            const downloadUrl = await uploadTask.snapshot.ref.getDownloadURL()
            // update firebase database
            this.updateUserInfo(uid, { profileImage: downloadUrl });
        });
}
 
     
    