Skip to content

Commit c4e01d5

Browse files
committed
Implement several fixes following the auto-check
1 parent 08eb0b0 commit c4e01d5

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

components/ip2location_io/actions/lookup-hosted-domain/lookup-hosted-domain.mjs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,23 @@ export default {
2727
},
2828
},
2929
async run({ $ }) {
30-
const response = await this.ip2location.lookupHostedDomain({
31-
params: {
32-
ip: this.ip,
33-
format: this.format,
34-
page: this.page,
35-
},
36-
});
37-
38-
if (response) {
39-
$.export("$summary", `Successfully retrieved hosted domains about IP ${this.ip}.`);
30+
try {
31+
const response = await this.ip2location.lookupHostedDomain({
32+
params: {
33+
ip: this.ip,
34+
format: this.format,
35+
page: this.page,
36+
},
37+
});
38+
if (response && response.total_domains) {
39+
$.export(
40+
"$summary",
41+
`Successfully retrieved hosted domain information about IP ${this.ip}.`
42+
);
43+
}
44+
return response;
45+
} catch (error) {
46+
throw new Error(`Error retrieving hosted domains: ${error.message}`);
4047
}
41-
42-
return response;
4348
},
44-
};
49+
};

components/ip2location_io/actions/lookup-ip-address/lookup-ip-address.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "ip2location_io-lookup-ip-address",
55
name: "Lookup IP Address",
66
description: "Retrieve geolocation data about an IP Address. [See the docs here](https://www.ip2location.io/ip2location-documentation)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
ip2location,

components/ip2location_io/ip2location_io.app.mjs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { axios } from "@pipedream/platform";
22

3+
const BASE_URL = "https://api.ip2location.io";
4+
const DOMAINS_URL = "https://domains.ip2whois.com/domains";
5+
36
export default {
47
type: "app",
58
app: "ip2location_io",
@@ -34,15 +37,33 @@ export default {
3437
...args,
3538
});
3639
},
40+
/**
41+
* Lookup geolocation information for an IP address
42+
* @param {Object} args - The arguments for the request
43+
* @param {Object} [args.params] - The query parameters
44+
* @param {string} [args.params.ip] - The IP address to lookup (IPv4 or IPv6)
45+
* @param {string} [args.params.format] - Response format (json or xml)
46+
* @param {string} [args.params.lang] - Translation information(ISO639-1) for continent, country, region and city name
47+
* @returns {Promise<Object>} The hosted domain information
48+
*/
3749
lookupIpAddress(args = {}) {
3850
return this._makeRequest({
39-
url: "https://api.ip2location.io",
51+
url: BASE_URL,
4052
...args,
4153
});
4254
},
55+
/**
56+
* Lookup hosted domains for an IP address
57+
* @param {Object} args - The arguments for the request
58+
* @param {Object} [args.params] - The query parameters
59+
* @param {string} [args.params.ip] - The IP address to lookup (IPv4 or IPv6)
60+
* @param {string} [args.params.format] - Response format (json or xml)
61+
* @param {number} [args.params.page] - Page number for pagination
62+
* @returns {Promise<Object>} The hosted domain information
63+
*/
4364
lookupHostedDomain(args = {}) {
4465
return this._makeRequest({
45-
url: "https://domains.ip2whois.com/domains",
66+
url: DOMAINS_URL,
4667
...args,
4768
});
4869
},

0 commit comments

Comments
 (0)