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

166
Views
Running the same API call with different params multiple times and compile into one json list

This API is giving me a limited number of participants (50 max). My problem is we would like to display more than 50 because this campaign will grow over 50 people. The documentation suggest to call it multiple times if you want to get more than that. The way to do that is in the params add 'filter: {"skip":50}' and that will give you 51-100. Then I want to be able to have all the calls compiled into one list so its easier to work with on the frontend.

Right now the way to do it would be to duplicate the code however many times I need to but then all the data would be separated in its own list. I also do not know how many times I will need to duplicate the code. I need it to be able to scale easily and not have to manually duplicate the code 50 times if needed.

Ideally, I would want to have a variable to loop through "options" however many times I need it to and get the number I need. Then run the code below and have everything in one list of json.

This is the api call that I have that is giving me a max of 50 participants. This is on the server side so it is creating a page of json for me to call to the frontend. This is what I mean by having all the calls compiled into 1 so on the client side I can make one call from this master list.

const router = express.Router();

const api_secret = process.env.API_SECRET

router.get('/', (req, res) => {
  const options = {
    method: 'GET',
    url: 'https://app.viral-loops.com/api/v2/participant_rank',
    params: {apiToken: api_secret},
    headers: {'Content-Type': 'application/json'}
  };
  
  axios.request(options).then(function (response) {
    let array = response.data.data
    let newUser = array.map(user => { return {user: {
      "firstname": user.user.firstname,
      "lastname": user.user.lastname,
      "rank": user.user.rank,
      "country": user.user.extraData.Vm7Tt6MH,
      "team": user.user.extraData._0bCLLf,
      "referrals": user.counters.referrals.total
    }}})
    res.json(newUser)
  }).catch(function (error) {
    console.error(error);
  });
});

app.use('/.netlify/functions/fetch-leaderboard', router);

This would be the options variable for the 2nd call. It would skip the first 50 to get 51-100.

const options = {
    method: 'GET',
    url: 'https://app.viral-loops.com/api/v2/participant_rank',
    params: {apiToken: api_secret, filter: {"skip":50},
    headers: {'Content-Type': 'application/json'}
  };
about 4 years ago · Santiago Gelvez
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!