SHOPIFY GET ALL products

tima4ka1
New Member
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((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?

0 Likes