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

269
Views
¿Cuál es la forma correcta de llamar a una función recursiva mientras se usa axios?

¿Esto me permitirá llamar recursivamente a una API sin ejecutarla indefinidamente? *** ¿Tengo que devolver la función o puedo simplemente llamarla dentro de la función?

 const apiUrl = "https://api.website.com/products"; let productArray = []; let lowPrice = 0; let highPrice = 100000; const countProduct = async (lowPrice, highPrice) => { const response = await axios.get(apiUrl, {`enter code here` params: { minPrice: lowPrice, maxPrice: highPrice } }); let lowerLimit = minPrice; let upperLimit = maxPrice; while (upperLimit > lowerLimit || response.data.count === 0) { if (response.data.count >= 1000) { countProduct(lowerLimit, (lowerLimit + upperLimit / 2)); // ***<--- Can I just call the function or do I have to return it } else { response.data.products.forEach(product => { if (product.price > lowerLimit) { lowerLimit = product.price; } productArray.push(product); }) lowerLimit = parseInt(lowerLimit + 0.01); upperLimit = parseInt(100000); } } };
about 4 years ago · Juan Pablo Isaza
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!