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

214
Views
How to bypass a value that does not exist in an asynchronous data fetch loop?

I wrote a script that will invoke a function on a blockchain that returns a value. I have to collect these values from 0 to 5999. Unfortunately, several dozen values do not exist, and the loop encountering them stops the operation. How to prevent it?

let uriArray = [];
   for (let tokenId = 0; tokenId < 5999; tokenId++) {
    let result = await Gateway.tokenURI(tokenId);
     console.log(result);
     uriArray.push(result);

     if (result = '') {
       continue;
     }
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use a try-catch, it is stopping I think every time there is a request error.

let uriArray = [];

for (let tokenId = 0; tokenId < 5999; tokenId++) {
  try{
      let result = await Gateway.tokenURI(tokenId);
      console.log(result);
      uriArray.push(result);
  }catch(e){
    console.log(e)
  }

}
about 4 years ago · Juan Pablo Isaza Report
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!