Hi all i am encountering an issue where my data is changed back to the original assignment. For example, I have the following data below:
data() {
return {
uid: "",
pic: "hello",
}
},
With the function below, the alert returns "hello"
created() {
this.uid = fb.auth().currentUser.uid;
this.getprofilepic();
},
** getprofilepic function
getprofilepic() {
fb.storage().ref('users/' + this.uid + '/profile.jpg').getDownloadURL().then(imgurl => {
this.pic = imgurl;
})
alert(this.pic); // returns "hello"
},
If i were to put the alert into the fb.storage..., it returns the correct path as shown below:
getprofilepic() {
alert("getting profile pic")
fb.storage().ref('users/' + this.uid + '/profile.jpg').getDownloadURL().then(imgurl => {
this.pic = imgurl;
alert(this.pic); // returns correct path;
})
},
Is there a reason why the data would override again? Thank you in advance for any help! :) I would like to v-bind:src to get the path of the photo from firebase storage but "pic" returns "hello" instead. You can find my html code below:
<b-avatar :src = "pic" id = "profilepic" class="mr-5" size="8em"></b-avatar>