@hackthedev/dsync-ipsec 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +13 -11
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -179,16 +179,18 @@ export default class dSyncIPSec {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// make request to get ip info
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
182
|
+
try{
|
|
183
|
+
let ipRequest = await fetch(`https://api.ipapi.is/?q=${ip}`);
|
|
184
|
+
if (ipRequest.status === 200) {
|
|
185
|
+
let ipData = await ipRequest.json();
|
|
186
|
+
|
|
187
|
+
// possibility to set cache
|
|
188
|
+
if(this.setCache && typeof this.setCache === "function") await this.setCache(ip, ipData);
|
|
189
|
+
|
|
190
|
+
return ipData;
|
|
191
|
+
} else {
|
|
192
|
+
return {error: "Failed to fetch IP data"};
|
|
193
|
+
}
|
|
194
|
+
}catch{}
|
|
193
195
|
}
|
|
194
196
|
}
|