Skip to content

Commit

Permalink
Merge pull request #2636 from techmatters/CHI-3143
Browse files Browse the repository at this point in the history
CHI-3143: Use placeholder IP if IPFind fails
  • Loading branch information
stephenhand authored Dec 11, 2024
2 parents abd4c2d + bebb9a7 commit 360f857
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions webchat/src/ip-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import { API_KEY } from '../private/secret';
const url = `https://ipfind.co/me?auth=${API_KEY}`; // Free Tier is 100 requests/day

export const getUserIp = async (): Promise<string> => {
const response = await fetch(url);
const responseBody = await response.json();
return responseBody.ip_address;
try {
const response = await fetch(url);
const responseBody = await response.json();
return responseBody.ip_address;
} catch (error) {
console.error(error);
return '0.0.0.0';
}
};

0 comments on commit 360f857

Please # to comment.