Is there a way to get the country code (Alpha-2) from a country name in JavaScript?
Is there a way to get the country code (Alpha-2) from a country name in JavaScript?
You can use this API https://restcountries.eu/
fetch("https://restcountries.eu/rest/v2/name/kenya").then(resp=>{
return resp.json();
}).then(json=>{
console.log(json[0].alpha2Code);
})