Skip to content

A JavaScript app that uses geocode api to detect location and return the flag and data from that country.

Notifications You must be signed in to change notification settings

nikkipurcell/js-where-am-i-flag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-where-am-i-flag

When a user clicks on the button, a function gets called. Inside the function is a fetch request that will detect where you are at and then return the flag and data from that country. If you are based in the US, it will return that flag. If you are in Italy, it will return that flag.

How Its Done

This app uses the fetch api and promises to handle the resolve and rejection for the api requests. Specifically there are nested apis that first use the geolocation api to figure out where you are, then passes that data to the GEOCODE API to do reverse geocoding. This takes the latitude and longitude and uses it to find the location data. Then finally that data is fed to the RESTCountries API to find the country so it can render a flag with data in the UI.

firstExample.js

This is the original way I did the whereAmI function without using the geolocation api and used the getJSON function to do the repeatable fetch function.

Where Am I Flag

About

A JavaScript app that uses geocode api to detect location and return the flag and data from that country.

Topics

Resources

Stars

Watchers

Forks