DEV Community


Discussion on: Not just another Coronavirus (covid-19) dashboard with live statistics

chan_austria777 profile image
chan 🤖

there's a widget that defaults to the current country of the viewer. Would you mind sharing how to do that?

otomer profile image
Tomer Ovadia Author

Hi @chan_austria777 , sure! I am basing my decision of what country to auto-select according to the client's public IP address. Note that it's not 100% correct since you might be using a VPN or something that alters your IP address but for my needs it was enough. To detect the IP address I am using the following API, specifically the following /GET endpoint which results with a simple JSON that you can retrieve the user's country code from.