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

180
Visualizações
(node:1788) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '4' of undefined

I have the following warning (check commented line in the code), and I don't know how to add the promise() object as my function is not asynchronous.

function MostProfitable() {
  var max = 0;
  var id;
  for (var i = 0; i < minmaxcoins.length; i++) {
    if (Number(minmaxcoins[i][4]) > Number(max)) {
      max = minmaxcoins[i][4];
      id = i;
    }
  }

  try {
    if (minmaxcoins[id][4] >= 0.6) { // error at this line
      console.info('Max coin: ', minmaxcoins[id][0], ' ', minmaxcoins[id][1]);
      console.info('Min coin: ', minmaxcoins[id][2], ' ', minmaxcoins[id][3]);
      console.info('Profit: ', minmaxcoins[id][4], '%');
      const d = new Date();
      opportunity = opportunity + 1;
      console.info(
        opportunity,
        ' ***********************************************',
        d
      );
      begin();
    }
  } catch (error) {
    console.error(error);
    begin();
  }
}

here's the error/ warning :

(node:1788) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '4' of undefined
    at MostProfitable (/home/root1/hft.js:274:20)
    at getMax (/home/root1/hft.js:261:2)
    at pairprice (/home/root1/hft.js:175:2)
    at getcoins (/home/root1/hft.js:116:1)
    at binance.bookTickers (/home/root1/hft.js:69:2)
    at Request.request [as _callback] (/home/root1/node_modules/node-binance-api/node-binance-api.js:3296:24)
    at Request.self.callback (/home/root1/node_modules/request/request.js:185:22)
    at Request.emit (events.js:198:13)
    at Request.<anonymous> (/home/root1/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:198:13)
(node:1788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1788) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I know it's just a warning but I notice that the app bugs as it's should work 24/7 non-stop. Can someone explain this problem?

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