Skip to content

Commit

Permalink
✨ (Info API) Added states fo Info API (#191)
Browse files Browse the repository at this point in the history
Added states also into the list of info we can get for a country
  • Loading branch information
anixsam authored Oct 17, 2024
1 parent d70a7c8 commit 6df8342
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions controllers/countryController.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,15 @@ class CountryController {
const fetchCities = params.includes('cities');
const fetchIso2 = params.includes('iso2');
const fetchIso3 = params.includes('iso3');
const fetchStates = params.includes('states');

const data = CountriesAndUnicodes.map((x) => {
const countryAndFlag = fetchImage && CountriesAndFlag.find((c) => c.name.toLowerCase() === x.Name.toLowerCase());

const Country = CountriesAndCities.find(({ country }) => country === x.Name);

const states = CountriesAndStates.find((c) => c.name.toLowerCase() === x.Name.toLowerCase());

return ({
name: x.Name,
currency: (fetchCurrency && x.Currency) || undefined,
Expand All @@ -520,6 +523,7 @@ class CountryController {
flag: (countryAndFlag && countryAndFlag.flag) || undefined,
dialCode: (fetchDialCode && x.Dial) || undefined,
cities: (fetchCities && Country && Country.cities) || undefined,
states: (fetchStates && states && states.states) || undefined,
iso2: (fetchIso2 && x.Iso2) || undefined,
iso3: (fetchIso3 && x.Iso3) || undefined,
});
Expand Down
2 changes: 1 addition & 1 deletion model/countriesAndUnicodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2444,7 +2444,7 @@ const CountriesAndUnicodes = [
Name: 'India',
Iso3: 'IND',
Unicode: '🇮🇳',
Dial: '91',
Dial: '+91',
Currency: 'INR',
Capital: 'New Delhi',
Continent: 'AS',
Expand Down
2 changes: 1 addition & 1 deletion model/countriesStateCity.js
Original file line number Diff line number Diff line change
Expand Up @@ -279083,7 +279083,7 @@ const data = [
"name": "India",
"iso3": "IND",
"iso2": "IN",
"phone_code": "91",
"phone_code": "+91",
"capital": "New Delhi",
"currency": "INR",
"states": [
Expand Down

0 comments on commit 6df8342

Please sign in to comment.