I'm using vuex action, it happen when I try to get the urlof the uploaded image everything is fine and the image is saved in firebase, but I can't get the downloadUrl and add it the reference of downloadurl to my meetup database
My code look like this
actions: {
createMeetup ({commit, getters}, payload) {
const meetup = {
title: payload.title,
location: payload.location,
description: payload.description,
date: payload.date.toISOString(),
creatorId: getters.user.id
}
let imageUrl
let key
firebase.database().ref('meetups').push(meetup)
.then((data) => {
key = data.key
return key
})
.then(key => {
const filename = payload.image.name
const ext = filename.slice(filename.lastIndexOf('.'))
return firebase.storage().ref('meetups/' + key + '.' + ext).put(payload.image)
})
.then(fileData => {
console.log(fileData)
imageUrl = fileData.metadata.downloadURLs[0]
return firebase.database().ref('meetups').child(key).update({imageUrl: imageUrl})
})
.then(() => {
commit('createMeetup', {
...meetup,
imageUrl: imageUrl,
id: key
})
})
.catch((error) => {
console.log(error)
})
}
fileData,key,filenamevalues exist? maybe just do console & comment out the output in your code