'Getting meta named object when Fetching data from Commerce js

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.



Solution 1:[1]

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 data key, which is normally an array of objects, doesn't get returned when no results are available.

Solution 2:[2]

Had the same issue fetching a specific product from commerce.js using a query parameter. Turns out the query parameter value had to be all lower case. At least it made it worked in my case. I hope this will help someone.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 scrowler
Solution 2 RascarCapcak