My catch block handle the promise rejection but I cannot log the error

Viewed 14

Guys maybe you can help me on this. Do you know why

Error while trying to get transaction from ${network} between ${startDate} and ${endDate}

is printed in the logger but the error it is not ?

try {
    const rawTransactions = await getTransactions(startDate, endDate);

    logger.info(`Job for network ${network} just finished. Time ellapsed: ${dayjs().diff(now, 'second')}s`);
  } catch (err) {
    logger.error(`Error while trying to get transaction from ${network} between ${startDate} and ${endDate}`);
    logger.error(err);
  }

The error occurs in getTransactions

async getTransactions(startDate, endDate) {
    const config = {
      method: 'get',
      url: `https://apiv2.effiliation.com/apiv2/transaction.json?key=${process.env.EFFILIATION_AUTH_TOKEN}&start=${dayjs(startDate, 'YYYY-MM-DD').format('DD/MM/YYYY')}&end=${dayjs(endDate, 'YYYY-MM-DD').format('DD/MM/YYYY')}&type=datetran&all=yes`,
    };
    const results = await axios(config);
    const transactions = results.data.rapport_effi_id;
    return transactions;
  }
0 Answers
Related