From 93dc509d69167adbe408ff3aa522a6e0504e9b1d Mon Sep 17 00:00:00 2001 From: Sergei Meza Date: Tue, 18 Oct 2022 11:16:14 +0900 Subject: [PATCH] save user ip on the window to cache it --- tracker/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tracker/index.js b/tracker/index.js index 98ed4229..dc82caca 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -86,14 +86,16 @@ const getClientIPAddress = () => { return new Promise((res, rej) => { - if (ip) { - res(ip); + if (window.ip) { + ip = window.ip; + res(window.ip); return; } fetch('https://api64.ipify.org/?format=json') .then(res => res.json()) .then(data => { ip = data.ip; + window.ip = data.ip; res(ip); return; })