How to get country name from country code in javascript

Viewed 26038

I am building a weather website, and I want to display the country name for the given location but my API request to openweathermap only returns country code. So is there a way to convert the country code to country name from javascript itself or I need to make one more API call to other url which will convert me the code to name.

3 Answers

If you search the internet hard enough, you might find a GitHub project or other piece of code that does this. But honestly your best bet is just to find the list of abbreviations and country names and build your own object. It really shouldn't take more than a half hour, at most

var atoc = {};
atoc.us = "United States";
atoc.uk = "United Kingdom";
...
Related