ipgeolocation
Advanced tools
Comparing version 1.0.2 to 1.0.7
19
index.js
@@ -11,4 +11,19 @@ exports.ipgeo = function(apiKey="",fields="",ip="") { | ||
function request(subUrl=null, apiKey="",fields="",ip=""){ | ||
var URL = ""; | ||
if(apiKey){ | ||
URL = subUrl; | ||
URL = URL + ("?apiKey=" + apiKey); | ||
} | ||
if(fields){ | ||
URL = URL + "&fields="; | ||
URL = URL + fields; | ||
} | ||
if(ip){ | ||
URL = URL + "&ip="; | ||
URL = URL + ip; | ||
} | ||
var data = null; | ||
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; | ||
var xhr = new XMLHttpRequest(); | ||
@@ -21,4 +36,4 @@ xhr.withCredentials = true; | ||
}); | ||
xhr.open("GET", "https://api.ipgeolocation.io/"+subUrl+"?apiKey="+apiKey+"&fields="+fields+"&ip="+ip+""); | ||
xhr.open("GET", "https://api.ipgeolocation.io/"+URL+""); | ||
xhr.send(data); | ||
} |
{ | ||
"name": "ipgeolocation", | ||
"version": "1.0.2", | ||
"version": "1.0.7", | ||
"description": "new pkg", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
1075
31