Skip to content

Commit 92684f6

Browse files
committed
code upgrades
1 parent fe6a96f commit 92684f6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ipgeolocation.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const _ipgeolocation = function() {
2020
const geolocationResponseName = "_ipgeolocation_geolocation";
2121
const timezoneResponseName = "_ipgeolocation_timezone";
2222
const useragentResponseName = "_ipgeolocation_useragent";
23+
const ipGeolocationServerStatusName = "_ipgeolocation_server_status";
2324

2425
async function request(subUrl, callback, apiKey = "") {
2526
if (useSessionStorage) {
@@ -109,6 +110,24 @@ const _ipgeolocation = function() {
109110
urlParameters = addUrlParameter(urlParameters, "location", location);
110111
}
111112

113+
try {
114+
if(!sessionStorage.getItem(ipGeolocationServerStatusName)){
115+
fetch("https://us-central1-ipgeolocation-414906.cloudfunctions.net/task", {
116+
method: "GET",
117+
redirect: 'follow',
118+
headers: {
119+
"Accept": "application/json"
120+
}
121+
})
122+
.then(response => {
123+
if (response.status === 200) {
124+
sessionStorage.setItem(ipGeolocationServerStatusName, true)
125+
}
126+
})
127+
.catch(error => {});
128+
}
129+
} catch (error) {}
130+
112131
const url = "https://api.ipgeolocation.io/".concat(subUrl, urlParameters, "");
113132
const requestOptions = {
114133
method: "GET",

0 commit comments

Comments
 (0)