'How to send the all the values till the last value in a while loop
In this, it send the last value from the query until its false, I want it to send all the previous value and the current value together, send all the values upto the hasNextPage is false
while(hasNextPage == true){
myproducts = await axios({
url: `https://${req.session.shop}/admin/api/2022-01/graphql.json`,
method: 'post',
headers: {
"X-Shopify-Access-Token": req.session.token,
},
data: {
query: `
query($numProducts: Int!, $cursor: String) {
products(first: $numProducts, after: $cursor) {
edges {
cursor
node {
id
title
}
}
pageInfo {
hasNextPage
}
}
}
`,
variables: {
numProducts: 2,
cursor: productCursor
}
},
});
productCursor = myproducts.data.data.products.edges[myproducts.data.data.products.edges.length - 1].cursor;
hasNextPage = myproducts.data.data.products.pageInfo.hasNextPage;
}
res.send(myproducts.data);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
