0
export async function getAllUsers() {   
// function to get the url of a firestore document   const myUrl = async (docId) => {     const myRef = ref(storage, `/profiles/${docId}.jpg\`);
return await getDownloadURL(myRef).then((url) =\> {
console.log("url : ", url);
return url.toString();
});
};

try {
// get all active users from cloud storage
const q = query(collection(db, "users"), where("appState", "==", true));
const querySnapshot = await getDocs(q);
const filteredData = querySnapshot.docs.map((doc) =\> ({
...doc.data(),
id: doc.id,
uri: "https://picsum.photos/200/300",
url: myUrl(doc.id),
}));

    //console.log("filteredData : ", filteredData);
    return filteredData;

} catch {
return {};
}}

I'm trying to add the url of the image profile to my filtered data.. ..the problem is that "myUrl" works, but too late... I get "url": {"_h": 0, "_i": 0, "_j": null, "_k": null} instead of "url": https://firebasestorage.googleapis.com/v0/b/testlogin-5f98e.appspot.com/o/profiles%2F4Ph9GC5Li9gumrMgiDFZWjXgwq53.jpg?alt=media&token=fcc46d4a-ed9f-40af-ae9e-b551d53def57...

LOG allUsers : [{"appState": true, "id": "4Ph9GC5Li9gumrMgiDFZWjXgwq53", "onCall": false, "pseudo": "PseudoB", "uri": "https://picsum.photos/200/300", "url": {"_h": 0, "_i": 0, "_j": null, "_k": null}}, {"appState": true, "id": "68kpA3tvx5ez69qGggNATd9nczc2", "onCall": false, "pseudo": "PseudoA", "uri": "https://picsum.photos/200/300", "url": {"_h": 0, "_i": 0, "_j": null, "_k": null}}]

LOG url : https://firebasestorage.googleapis.com/v0/b/testlogin-5f98e.appspot.com/o/profiles%2F4Ph9GC5Li9gumrMgiDFZWjXgwq53.jpg?alt=media&token=fcc46d4a-ed9f-40af-ae9e-b551d53def57

I have tried to take my function "myUrl" outside of "getAllUsers", I have tried to declare it without the async/await... ...no result... :s :s

Edouard
  • 15
  • 5

0 Answers0