Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

432
Vistas
Random Fetch Error when I restart my program

I'm looping through this array of names and using each name to change the end point in the URI. The data from the end points is then stored in a Promise.all() array. I then run the array through a for loop and outputs the data into an EJS file. This works sometimes. However sometimes the console logs the error at the bottom of this post. When I increase the amount of endpoints i'm requesting this error happens everytime. The error appears to be very random and the error stops at random endpoints. I'm assuming i'm maybe sending to many requests? I eventually want to loop through around 5000 endpoints in this code but i'm struggling just loop through 20. Any help is much appreciated.

  body: new URLSearchParams({ grant_type: 'client_credentials' }),
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Authorization': 'Basic ' + Buffer.from(appId + ':' + appSecret).toString('base64')
  }
})
.then(response => response.json())
.then(token2 => secondtoken(token2))

function secondtoken(token2){
let accesstoken = token2.access_token; 
const promises = [];
for(var i = 0; i < 20;i++){
promises.push(fetch('https://us.api.blizzard.com/profile/wow/character/'+ slug[i]+'/'+ lowercasenames[i] +'?namespace=profile-us&locale=en_US', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${accesstoken}`
    }
  })
  .then(response => response.json()))

}
  Promise.all(promises)
  .then(data => { profiledata(data)})

};
  
function profiledata(data){
  const name = []
  for(var i = 0; i < data.length;i++){
  name.push(data[i].name)
};

console.log(name)
  res.render('index', {
    leaderboard: diomerda,
    rank: rank,
    rating: rating,
    slug: slug,
    faction: faction,
    statsplayed: statsplayed,
    statswon: statswon,
    statslost: statslost,
    race: racename,
    name: name,
   })
  }}});```

The error is below:

D:\Coding\Form 1\node_modules\node-fetch\lib\index.js:1461
                        reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
                               ^
FetchError: request to https://us.api.blizzard.com/profile/wow/character/area-52/toonah?namespace=profile-us&locale=en_US failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (D:\Coding\Form 1\node_modules\node-fetch\lib\index.js:1461:11)
    at ClientRequest.emit (node:events:520:28)
    at TLSSocket.socketErrorListener (node:_http_client:442:9)
    at TLSSocket.emit (node:events:520:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}


over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I have exact same problem here, did you find the solution for this?

about 4 years ago · Akmal Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda