I am trying to fetch data from commerce.js by following documentation. After fetching data I am getting a object named Meta.
function fetchProducts() {
commerce.products.list()
.then((res) => {console.log("products Data",res);})
.catch((error) => {console.log('There was an error fetching the products', error);});
}
useEffect(()=>{
fetchProducts();
}, [])
output == products Data {meta: {…}}meta: {pagination: {…}}[[Prototype]]: Object
I don't know if it is working fine, or there are any mistakes from my side. As per documentation, It is an array of objects not meta.
Robbie from the Commerce.js team here. It looks as if no products are being returned in your account. Do you have any set up?
We have a known issue where the
datakey, which is normally an array of objects, doesn't get returned when no results are available.