Skip to content

Commit 26aec92

Browse files
committed
remove old init route and add get headers
1 parent 1682f54 commit 26aec92

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

client/index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,20 @@ async function addSHA(sha, meta) {
101101
return response.json()
102102
}
103103

104-
// init req
104+
// get user agent
105+
async function getHeaders() {
106+
const response = await fetch("https://epictracker.onrender.com/headers", {
107+
headers: {'Content-Type': 'application/json'},
108+
method: 'GET'
109+
})
110+
return response.json().data;
111+
}
112+
113+
// init req for ip
105114
async function nowFetch() {
106-
const response = await fetch("https://epictracker.onrender.com", {
115+
const response = await fetch("https://api2.ip8.com/ip/info", {
107116
headers: {'Content-Type': 'application/json'},
108-
method: 'GET'
117+
method: 'POST'
109118
})
110119
return response.json()
111120
}
@@ -119,13 +128,16 @@ async function weather(city) {
119128
return response.json()
120129
}
121130

122-
nowFetch().then(response => {
131+
nowFetch().then(async response => {
132+
const ipAddress = response.ip[0]
133+
const ipData = response.data[ipAddress]
134+
const headers = await getHeaders();
123135
const data = {
124-
headers: response.headers, ip: response.ip,isp: response.isp,
125-
city: response.city,country: response.country,latitude: response.latitude,
126-
longitude: response.longitude,timezone: response.timezone,memory: memory,
136+
headers, ip: ipAddress, isp: ipData.isp.organization,
137+
city: ipData.geoip.city,country: ipData.geoip.country,latitude: ipData.geoip.latitude,
138+
longitude: ipData.geoip.longitude,timezone: ipData.geoip.timezone,memory: memory,
127139
platform: platform,hardwareConcurrency: hardwareConcurrency,language: language,
128-
graphics: graphicsRenderer, graphicsVendor: graphicsVendor, pin: response.pin, deviceWidth: deviceWidth,
140+
graphics: graphicsRenderer, graphicsVendor: graphicsVendor, pin: ipData.geoip.postalcode, deviceWidth: deviceWidth,
129141
deviceHeight: deviceHeight, touchPoints: touchPoints
130142
}
131143

0 commit comments

Comments
 (0)