Skip to content

Commit

Permalink
Merge pull request #961 from tsg-ut/nmpz-country-name-source
Browse files Browse the repository at this point in the history
nmpz: change country name source
  • Loading branch information
sh-mug authored Nov 3, 2024
2 parents 3788df4 + a2c0084 commit d30a268
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions nmpz/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ const getRandomCoordinate = async () => new Promise((resolve, reject) => {
});

const getCountryName = async (country_code: string): Promise<Country> => new Promise((resolve, reject) => {
const url = `https://restcountries.com/v3.1/alpha/${country_code}`;
const url = "https://raw.githubusercontent.com/sh-mug/countries/fix-jpn-translations/countries.json";
fetch(url)
.then((response) => response.json())
.then((data) => {
const country = data[0];
const country = data.find((c: any) => c.cca2 === country_code.toUpperCase());
if (!country) {
reject(new Error("Country not found"));
return;
}
const region = country.region;
const subregion = country.subregion;
const name_official = country.translations.jpn.common;
const name_common = country.translations.jpn.official;
const name_official = country.translations.jpn.official;
const name_common = country.translations.jpn.common;
resolve({ country_code, region, subregion, name_official, name_common });
})
.catch((error) => {
Expand Down

0 comments on commit d30a268

Please sign in to comment.