How can I successfully retrieve all product data from a Shopify store?

How can I successfully retrieve all product data from a Shopify store?

tima4ka1
Visitor
3 0 0

Hey!


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((resolvereject) => {
      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();
      }
      })
   })
}
 
I also looked and I get an error:
 
status: 401,
statusText: 'Unauthorized',


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

Replies 0 (0)