I want to make a async Function work in parallel for the .map loop.
Also when I call it like below I get ‘Promise ’ eg
console.log(getExchangeRate(variable));
Hey I am trying to run a Async function in NodeJS where inside it does some calculations in parallel.
const getExchangeRate = async (orderBaseCurrency) => {
try {
const exchangeRate = await axios.get(`http://api.example.com`);
const data = exchangeRate.data.data.rates;
const usd = data.usd;
const aud = data.aud;
// loop through above with the calc below in parallel
const decimalEntry = new Decimal(1);
const answer = new Decimal(decimalEntry.times(orderAmount).toFixed(18, Decimal.ROUND_HALF_UP));
return answer.toPrecision();
//^^ loop
} catch (error) {
console.error(error);
console.log(error);
}
}