app.js
//convert the location to a Geocode Latitude and longitude(latLong)
convert the location to a Geocode Latitude and longitude(latLong)
convert the location to a Geocode Latitude and longitude ( latLong )
function fetchGeocode(locationName){
	opencage.geocode({q: locationName}).then(data => {
	  console.log(JSON.stringify(data));
	  if (data.status.code == 200) {
	    if (data.results.length > 0) {
	      const place = data.results[0];
	      console.log(place.formatted);
	      console.log('Location Name:', place.formatted);
	      console.log('lat-long:', place.geometry);
	      console.log('Location Timezone:', place.annotations.timezone.name);
	      console.log('fetching the current time of this location...');
	      const latLng = place.geometry['lat']+", " + place.geometry['lng'];
	      getLocationTime(latLng);
	    }
	  } else if (data.status.code == 402) {
	    console.log('free-trial daily limit reached');
	  } else {
	    console.log('error', data.status.message);
	  }
	}).catch(error => {
	  console.log('error', error.message);
	});
}
function fetchGeocode ( locationName ) { opencage . geocode ( { q : locationName } ) . then ( data => { console . log ( JSON . stringify ( data ) ) ; if ( data . status . code == 200 ) { if ( data . results . length > 0 ) { const place = data . results [ 0 ] ; console . log ( place . formatted ) ; console . log ( 'Location Name:' , place . formatted ) ; console . log ( 'lat-long:' , place . geometry ) ; console . log ( 'Location Timezone:' , place . annotations . timezone . name ) ; console . log ( 'fetching the current time of this location...' ) ; const latLng = place . geometry [ 'lat' ] + ", " + place . geometry [ 'lng' ] ; getLocationTime ( latLng ) ; } } else if ( data . status . code == 402 ) { console . log ( 'free-trial daily limit reached' ) ; } else { console . log ( 'error' , data . status . message ) ; } } ) . catch ( error => { console . log ( 'error' , error . message ) ; } ) ; }
convert the location to a Geocode Latitude and longitude(latLong)
convert the location to a Geocode Latitude and longitude ( latLong )
//request the location time with the informationobtained // other possible response codes: