0

我正在编写一个从https://restcountries.eu/中提取国家/地区的程序, 我正在使用数据保存在我的 mongo DB 中并更新它。ofc,数据不会经常变化,但这是十年前的事情。

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
    })))));

现在当数据在数据库中时,我想用它来映射我从其他 API 获得的其他实体,例如体育游戏。但游戏带有国家的替代名称(例如英格兰而不是大不列颠)。

有没有办法将国家的替代名称映射到 iso 3166 名称/id?

4

1 回答 1

1

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

于 2019-02-14T14:56:48.483 回答