问题描述
是否可以从JavaScript中的国家/地区名称中获取国家/地区代码(Alpha-2)?
解决方法
您可以使用此API https://restcountries.eu/
fetch("https://restcountries.eu/rest/v2/name/kenya").then(resp=>{
return resp.json();
}).then(json=>{
console.log(json[0].alpha2Code);
})
是否可以从JavaScript中的国家/地区名称中获取国家/地区代码(Alpha-2)?
您可以使用此API https://restcountries.eu/
fetch("https://restcountries.eu/rest/v2/name/kenya").then(resp=>{
return resp.json();
}).then(json=>{
console.log(json[0].alpha2Code);
})