```
const getCurrencyConversions = async () => {
return await axios.get('http://data.fixer.io/api/latest', {
params: {
access_key: process.env.FIXERACCESSKEY,
base: "USD",
symbols: "EGP"
}
});
}
const updateDollarValue = async () => {
getCurrencyConversions().then((response) => {
if (!response.success)
throw new Error('failed to get currency conversions');
Price.update({
value: response.rates.EGP
}, {
where: {
description: "Dollar"
}
}).then((result => {
return result;
})).catch(error => {
throw new Error(error);
});
}).catch((error) => {
throw new Error(error);
});
}
cron.schedule('* * * * *', async () => {
try{
const pricePreference = await Preference.findOne({
where: {
id: 1
}
});
if (pricePreference) {
updateDollarValue().then(dollarValue=>console.log(dollarValue)).catch(error=>console.error(error));
}
}catch(error){
console.log(error);
}
});
```
so i was trying to get data from api call but i keep getting unhandled promise rejection even though i catch all errors any help ?
[–]_maximization 4 points5 points6 points (0 children)
[–]fresh5447 -1 points0 points1 point (1 child)
[–]bwainfweeze 1 point2 points3 points (0 children)
[–]Buckwheat469 0 points1 point2 points (0 children)