@@ -48,20 +48,29 @@ var ipgeolocationApi = new IPGeolocationAPI("YOUR_API_KEY");
4848var GeolocationParams = require (' ip-geolocation-api-javascript-sdk/GeolocationParams.js' );
4949
5050// Query geolocation for the calling machine's IP address for all fields
51- console .log (ipgeolocationApi .getGeolocation ());
51+ ipgeolocationApi .getGeolocation (null , geoResponse);
52+ function geoResponse (json ) {
53+ console .log (json);
54+ }
5255
5356// Query geolocation for IP address (1.1.1.1) and all fields
5457var geolocationParams = new GeolocationParams ();
5558geolocationParams .setIp (" 1.1.1.1" );
5659
57- console .log (ipgeolocationApi .getGeolocation (geolocationParams));
60+ ipgeolocationApi .getGeolocation (geolocationParams, geoResponse);
61+ function geoResponse (json ) {
62+ console .log (json);
63+ }
5864
5965// Query geolocation for IP address (1.1.1.1) and fields (geo, time_zone and currency)
6066var geolocationParams = new GeolocationParams ();
6167geolocationParams .setIp (" 1.1.1.1" );
6268geolocationParams .setFields (" geo,time_zone,currency" );
6369
64- console .log (ipgeolocationApi .getGeolocation (geolocationParams));
70+ ipgeolocationApi .getGeolocation (geolocationParams, geoResponse);
71+ function geoResponse (json ) {
72+ console .log (json);
73+ }
6574```
6675
6776### Bulk Geolocations Lookup
@@ -71,14 +80,20 @@ console.log(ipgeolocationApi.getGeolocation(geolocationParams));
7180var geolocationParams = new GeolocationParams ();
7281geolocationParams .setIps ([' 1.1.1.1' , ' 2.2.2.2' , ' 3.3.3.3' ]);
7382
74- console .log (ipgeolocationApi .getGeolocation (geolocationParams ));
83+ ipgeolocationApi .getGeolocation (geolocationParams , geoResponse );
84+ function geoResponse(json ) {
85+ console .log (json );
86+ }
7587
7688// Query geolocations for multiple IP addresses but only 'geo' field
7789var geolocationParams = new GeolocationParams ();
7890geolocationParams .setIps ([' 1.1.1.1' , ' 2.2.2.2' , ' 3.3.3.3' ]);
7991geolocationParams .setFields (" geo" );
8092
81- console .log (ipgeolocationApi .getGeolocation (geolocationParams ));
93+ ipgeolocationApi .getGeolocation (geolocationParams , geoResponse );
94+ function geoResponse(json ) {
95+ console .log (json );
96+ }
8297```
8398
8499### Time Zone API
@@ -90,20 +105,32 @@ var TimezoneParams = require('ip-geolocation-api-javascript-sdk/TimezoneParams.j
90105var timezoneParams = new TimezoneParams ();
91106timezoneParams .setTimezone (" America/New_York" );
92107
93- console .log (ipgeolocationApi .getTimezone (timezoneParams ));
108+ ipgeolocationApi .getTimezone (timezoneParams , geoResponse );
109+ function geoResponse(json ) {
110+ console .log (json );
111+ }
94112
95113// Query time zone information by latitude and longitude of the location
96114var timezoneParams = new TimezoneParams ();
97115timezoneParams .setLocation (37.1838139 , - 123.8105225 );
98116
99- console .log (ipgeolocationApi .getTimezone (timezoneParams ));
117+ ipgeolocationApi .getTimezone (timezoneParams , geoResponse );
118+ function geoResponse(json ) {
119+ console .log (json );
120+ }
100121
101122// Query time zone information for IP address (1.1.1.1)
102123var timezoneParams = new TimezoneParams ();
103124timezoneParams .setIp (" 1.1.1.1" );
104125
105- console .log (ipgeolocationApi .getTimezone (timezoneParams ));
126+ ipgeolocationApi .getTimezone (timezoneParams , geoResponse );
127+ function geoResponse(json ) {
128+ console .log (json );
129+ }
106130
107131// Query time zone information for calling machine’s IP address
108- console .log (ipgeolocationApi .getTimezone ());
132+ ipgeolocationApi .getTimezone (null , geoResponse );
133+ function geoResponse(json ) {
134+ console .log (json );
135+ }
109136```
0 commit comments