nodejs - iso 3166 - 替代国家名称

问题描述 投票:0回答:1

我正在编写一个程序,从https://restcountries.eu/中提取国家我正在使用数据保存在我的mongo数据库中并更新它。 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?

node.js mongodb api dictionary iso-3166
1个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.