Skip to main content

Get my IP Address Callback

  • Purpose:
    Retrieves the client's IP address.

  • Functionality:

    • Uses an asynchronous fetch with retry logic (up to three attempts) to obtain the IP address.
    • Returns the IP address once successfully retrieved or an empty string if all attempts fail.
  • Usage:
    Provides network information necessary for the agent’s operations.

  • Example:

 getMyIpAddressCallback: async () => {
for (let retry = 0; retry < 3; retry++) {
try {
const response = await fetch('https://secure.one37id.com/ip');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log('---data:', data?.client_ip);
return data?.client_ip ?? '';
} catch {
await new Promise(resolve => setTimeout(resolve, 200 * (retry + 1)));
}
}
return '';
},

X

Graph View