I believe this issue is related to JS in general as opposed to VueJS. But I have the following Vue Method that returns a Firebase Call and returns the object asked for. This is working:
methods: {
getSponsor (key) {
db.ref('businesses').child(key).on('value', snap => {
console.log(snap.val())
return snap.val()
})
}
}
[Object]
Now, when I call this method from a computed property, it results in undefined:
computed: {
sponsor () {
console.log(this.getSponsor(key))
return(this.getSponsor(key))
}
}
Undefined
Why is this? Is it because of how I return my method?
getSponsordoes not return anything. It just executes some async code.getSposorinto a function and return that function? Sorry, my JS understanding is a little sub-par.