I am facing an issue with my Vue 3 application. I am trying to retrieve a link to a document from the repository, but all I keep getting is a promise instead of the actual link. Can someone help me understand why this is happening?
async FetchData({ state, commit }, to) {
try {
commit("setLoading", true);
const q = query(collection(db, to));
await onSnapshot(q, (querySnapshot) => {
const data = [];
querySnapshot.forEach((doc) => {
let films = async (to) => {
const starsRef = ref(storage, `images/${doc.id}/poster.png`);
return await getDownloadURL(starsRef);
};
// const poster=`gs://cell-11ef4.appspot.com/images/${doc.id}/poster.png`
let item = {
id: doc.id,
name: doc.data().name,
slug: doc.data().slug,
country: doc.data().country,
duration: doc.data().duration,
year: doc.data().year,
video: doc.data().video,
genres: doc.data().genres,
actors: doc.data().actors,
poster: to === "films" ? films() : null,
// BipPoster: url,
};
data.push(item);
// Get the download URL
});
commit("setData", { data, to });
});
} catch (err) {
console.log(err);
} finally {
commit("setLoading", false);
}
}
let url = async () => {
let url;
const starsRef = ref(storage, `images/${doc.id}/poster.png`);
await getDownloadURL(starsRef).then((p) => {
url = p;
});
return url;
};
The Output I am currently getting:
https://i.sstatic.net/FXYdI.png
https://i.sstatic.net/Etf0O.png https://i.sstatic.net/zrjn8.png