Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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);
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!