module.exports = function geoip (ip) {
  return (state, emitter) => {
    state.geoip = {
      ip: ip,
      isLoading: false
    }

    emitter.on('geoip:fetch', () => {
      if (state.geoip.isLoading) return
      state.geoip.isLoading = true

      window.fetch('//api.ipify.org?format=json')
        .then(body => body.json())
        .then(resp => window.fetch(`//freegeoip.net/json/${resp.ip}`))
        .then(body => body.json())
        .then(data => {
          Object.assign(state.geoip, data, {
            isLoading: false,
            precision: 'city'
          })
          emitter.emit('render')
        }, err => {
          state.geoip.isLoading = false
          emitter.emit('error', err)
        })
    })

    emitter.on('geoip:getPosition', () => {
      state.geoip.isLoading = true
      emitter.emit('render')

      navigator.geolocation.getCurrentPosition(position => {
        state.geoip.latitude = position.coords.latitude
        state.geoip.longitude = position.coords.longitude
        state.geoip.precision = 'exact'
        state.geoip.isLoading = false

        emitter.emit('render')
      }, err => emitter.emit('error', err))
    })
  }
}

@@ -265,46 +265,37 @@
 ch('
-//api.ipify.org?format=
+https://freegeoip.net/
 json
+/
 ')
-%0A        
 .the
@@ -308,113 +308,24 @@
  =%3E 
-body.json())%0A        .then(resp =%3E window.fetch(%60//freegeoip.net/json/$%7Bresp.ip%7D%60))%0A        .then(body =%3E
+%7B%0A        return
  bod
@@ -332,26 +332,16 @@
 y.json()
-)%0A        
 .then(da
@@ -504,26 +504,41 @@
 ')%0A        %7D
-, 
+)%0A      %7D).catch(
 err =%3E %7B%0A   
@@ -530,26 +530,24 @@
 ch(err =%3E %7B%0A
-  
         stat
@@ -572,34 +572,32 @@
 = false%0A        
-  
 emitter.emit('er
@@ -607,18 +607,16 @@
 ', err)%0A
-  
       %7D)

Remove use of ipify.org service