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

(Info API) Added states for Info API #191

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading