-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetchCurrencies() #4
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kindly also remove the package-lock.json. we don't need it as we have yarn-lock.json
You should update readme with how to use the piece of code you added
Rem to do a commit to link this to the open issue, or tag it manually
In future, remember to request for reviews for PRs to be seen in time
@@ -56,6 +57,28 @@ function getCities(filter) { | |||
) | |||
} | |||
|
|||
async function fetchCurrencies() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name should be descriptive to what the function does , getCountriesWithCurecy
); | ||
countryCurrencies[country] = currencyData.currencies; | ||
} catch (error) { | ||
console.error(`Failed to fetch currency for ${country}:`, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather suggest we return an empty currency field, rather than throw an error, this is to have consistent currency type|I'll prefer string | null
to string | undefined
@@ -1,4 +1,5 @@ | |||
const countriesData = require("./country-cities.json") | |||
const CurrencyExplorer = require('currency-explorer'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this constant should be camel case
also we only need const { currencies } = require('currency-explorer');
also kindly lazy load this inside fetchCurrencies
as it's only used there
@cliffgor could we also get the ability to get currency for a particular country? |
@cliffgor Added an async function to fetch currencies from the CurrenExplorer package and attach it to each country