handleError(response)
Checks an API response for errors. If an error is encountered, the appropriate Error
is thrown.
Parameters:
Name |
Type |
Description |
response |
object |
The response from a services.rest request.
|
-
See:
-
Throws:
-
-
HttpRequestError
-
Thrown when the year is not supported or another parameter is invalid.
-
-
HttpNotFoundError
-
Thrown when the country code is not recognised or the requested endpoint is not found.
-
-
HttpServerError
-
Thrown when the API responded with a server error.
Example:
try {
connectors.verjio.ip2location.query(fields.ip.value);
}
catch (e) {
if (e instanceof HttpRequestError) {
event.owner.addErrorMessage(e.message);
}
if (e instanceof HttpServerError) {
event.owner.addErrorMessage('Unable to get IP location');
}
}
query(ip) → (nullable) {object}
Retrieves the location of a specified IP address.
Parameters:
Name |
Type |
Description |
ip |
string |
IP address to query.
|
Returns:
object
API response object containing location and network details. Returns null
if the IP address was omitted.
Examples:
// Get location details for a specific IP address
const details = connectors.verjio.ip2location.query(fields.ip.value);
fields.location.value = `${details.city_name}, ${details.region_name}, ${details.country_name}`;
fields.lat.value = details.latitude;
fields.lng.value = details.longitude;
// Get location details for the requesting user
// e.g. the IP of the user connecting to the form or service
connectors.verjio.ip2location.query(client.request.remoteAddr);