I'm starting in the world of promises and there is one thing I can't understand.
I am trying to make a system that returns a document from a Firebase collection by its ID.
For this I use 2 functions
const getProductDataById = async(idProduct)=> {
const docSnap = await getDoc(doc(db, "products", idProduct));
if (docSnap.exists()) {
return docSnap.data();
}
else {
console.log("No such document!");
}
}
const getProduct = (idProduct)=>{
let ProductDataPromise = getProductDataById (idProduct);
//I don't know how resolve Promise
return ProductData;
}
The problem is that I don't know in the second how to resolve the Promise so that this function returns the desired object.
Thanks!!