Skip to content
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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

fetchCurrencies() #4

wants to merge 2 commits into from

Conversation

cliffgor
Copy link

@cliffgor Added an async function to fetch currencies from the CurrenExplorer package and attach it to each country

cliffgor added 2 commits May 25, 2023 12:02
@cliffgor Added an async function to fetch currencies from the CurrenExplorer package and attach it to each country
@cliffgor Added the fetchCurrencies function on the exports
Copy link
Member

@manuelgeek manuelgeek left a 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() {
Copy link
Member

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);
Copy link
Member

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');
Copy link
Member

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

@manuelgeek manuelgeek linked an issue Jun 12, 2023 that may be closed by this pull request
@manuelgeek
Copy link
Member

@cliffgor could we also get the ability to get currency for a particular country?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Addition of Currency Codes
2 participants