V
V
VovaVist2021-09-16 21:44:26
Node.js
VovaVist, 2021-09-16 21:44:26

Why does UnhandledPromiseRejectionWarning: Error: Request failed with status code 500 occur?

I run the code, but in the console it gives an error

UnhandledPromiseRejectionWarning: Error: Request failed with status
code 500
as well as
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`


As for the second one, somewhere in the code you need to put error handling .catch
Here is the code itself from Index.js
If you really need .catch, tell me where to insert it

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);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question