Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
How to call the same API multiple times and compile all of the calls together

I am trying to figure out the best way to call this API multiple times and compile all the calls into one list of json. This API only allows a limit of 50 users(json data items) per call. The only thing that will change from call to call is the filter params. Ex: params: {"filter: skip=50"} would skip the first 50 and the next call would be skip=100. The code below would be the first call. I am trying to not manually do the calls because depending on how many people are in the campaign we are running I might have to run this 50+ times.

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);
about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda