简体   繁体   中英

Shopify get all products

I am creating an application and at the moment I am trying to get all product data from the store, but the function does not work for me.

I am making a request for this feature, but in the response I have no 'link' at all. And there is no other replacement that would link to the next page.

function makeRequest(
  nextLink = 'https://myshopname.myshopify.com/admin/api/2021-04/products.json?limit=1'
) {
  return new Promise((resolve, reject) => {
    console.log(nextLink);
    fetch(nextLink).then((r) => {
      const headerLink = r.headers.get('link');
      console.log(r.headers);
      console.log(headerLink);
      const match = headerLink.match(/<[^;]+\/(\w+\.json[^;]+)>;\srel="next"/);
      const nextLink = match ? match[1] : false;
      if (nextLink) {
        makeRequest(nextLink);
      } else {
        resolve();
      }
    });
  });
}

Can you help me figure out how I can make this function work and how can I get all the data from this store?

If someone were looking for an answer to the same question, the answer turned out to be very simple. For this feature to really work, you need a Shopify Plus store subscription. If you have it, but the code still does not work, then you need to contact Shopify technical support and write to them about this problem. If you need to get all the products from the store, then I recommend using another way to get data, namely through GraphiQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM