You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
447 B

  1. var ipLocation = require('ip-location')
  2. ipLocation.httpGet = function (url, callback) {
  3. var xhr = new XMLHttpRequest()
  4. xhr.open('get', url, true)
  5. xhr.responseType = 'text'
  6. xhr.onreadystatechange = function () {
  7. if (xhr.readyState === 4) {
  8. if (xhr.status === 200) {
  9. callback(null, { body: xhr.responseText })
  10. } else {
  11. callback(xhr.responseText)
  12. }
  13. }
  14. }
  15. xhr.send()
  16. }
  17. module.exports = ipLocation