@VovaVist

Почему возникает ошибка UnhandledPromiseRejectionWarning: Error: Request failed with status code 500?

Запускаю код, но в консоли выдает ошибку
UnhandledPromiseRejectionWarning: Error: Request failed with status
code 500
а также
essTicksAndRejections (internal/process/task_queues.js:82:21)
(node:9772) 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(). To termina
te the node process on unhandled promise rejection, use the CLI flag `--unhandle
d-rejections=strict`


Что по поводу второй, где-то в коде нужно поставить обработку ошибок .catch
Вот сам код из Index.js
Если и правда требуется .catch, подскажите куда его надо будет вставить

require('dotenv').config();
const nft = require('./api/InfoNFT');
const userInfo = require('./api/getUserInfo');
const getPackInfo = require('./api/getPackInfo');
const buyCurrentBox = require('./api/buyCurrentBox');

main = async () => {
  /*const nftInfo = await nft.getNft();
  const ar = {};
  nftInfo.map((item) => {
    ar[item.name] = item.productId;
  });
  console.log(ar);
  // console.log(nftInfo);
  const user = await userInfo.getInfo();
  console.log(user.data.data.email);

  const packInfo = await getPackInfo('134199284294874112');
  const packRes = packInfo.data.data;
  //console.log(packInfo);
  console.log(
    `Pack Price ${packRes.price}\n Pack Name ${packRes.name}\n Limit ${packRes.limitPerTime}\n StartTime ${packRes.startTime}\n DELAY ${packRes.secondMarketSellingDelay}`
  ); */
  buyCurrentBox('134199284294874112', 20).then((res) => console.log(res)); 
  //console.log(buyCurrPack);
};

let resultTimeout = setInterval(() => main(), 50);

setTimeout(() => {
  clearInterval(resultTimeout);
  console.log('stop');
}, 9000);
  • Вопрос задан
  • 154 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы