In the function orderBy when passing the "desc" parameter, it does not return data, but when passing "asc" or blank, there is data.
const getListProduct = async () => {
const products = await fs
.collection("products")
.orderBy("createAt", "desc") //problem is here.It just works orderBy("createAt", "asc") or orderBy("createAt")
.startAfter(0)
.limit(5)
.get();
let listProduct = [];
for (let snap of products.docs) {
let data = snap.data();
data.ID = snap.id;
listProduct.push({ id: snap.id, ...data });
if (products.docs.length === listProduct.length) {
setListData(listProduct);
}
}
};