简体   繁体   中英

nodejs - iso 3166 - Alternative countries names

I'm writing a program that extracts countries from https://restcountries.eu/ I'm using the data to save in my mongo DB and update it. ofc, the data doesn't change too often, but this is for a decade forward.

const COUNTRIES_URL = 'https://restcountries.eu/rest/v2/all';
const axios = require('axios');

exports.httpCrawl = () => (
  axios.get(COUNTRIES_URL).then(response => (
    response.data.map(country => ({
      name: country.name,
      digits2: country.alpha2Code,
      digits3: country.alpha3Code,
      countryId: country.numericCode,
      flag: country.flag
    })))));

now when the data is in the DB, I want to use it to map other entities I'm getting from other APIs, for example, sports games. but the games come with the country's alternative name (for example England instead of Great Britain).

Is there a way to map the country's alternative names to the iso 3166 name/id?

您可以利用Google Places API之类的服务,这将使您能够根据备用名称或部分信息提取相关的国家/地区信息。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM