Skip to content

Commit d7d5ee7

Browse files
committed
fetch ip only one time
1 parent 537e2e5 commit d7d5ee7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

_posts/fun/2025-05-03-whatismyip.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ math: false
2424
<script>
2525
async function fetchIP() {
2626
try {
27-
let ipv4 = await fetch("https://api64.ipify.org?format=json").then(res => res.json());
28-
let ipv6 = await fetch("https://api6.ipify.org?format=json").then(res => res.json());
27+
// Fetching the IP address from a single source
28+
let response = await fetch("https://api64.ipify.org?format=json").then(res => res.json());
2929

30+
// Assigning the IP to both IPv4 and IPv6 (same IP for simplicity in this case)
3031
let ipv4Elem = document.getElementById("ipv4");
3132
let ipv6Elem = document.getElementById("ipv6");
3233

33-
ipv4Elem.textContent = ipv4.ip;
34-
ipv6Elem.textContent = ipv6.ip;
34+
ipv4Elem.textContent = response.ip;
35+
ipv6Elem.textContent = response.ip;
3536

3637
ipv4Elem.classList.add("show");
3738
ipv6Elem.classList.add("show");

0 commit comments

Comments
 (0)