Added geo ipcode

This commit is contained in:
vjrj 2017-11-30 17:21:59 +01:00
parent 287a7529a6
commit 6f5f094082
4 changed files with 20 additions and 0 deletions

View file

@ -40,3 +40,4 @@ gadicc:blaze-react-component # Add braze to react
mixmax:smart-disconnect # Disconnect on lost focus
flowkey:raven # js errors
davidsichau:piwik # Stats
thebakery:ipgeocoder

View file

@ -102,6 +102,7 @@ templating@1.3.2
templating-compiler@1.3.3
templating-runtime@1.3.2
templating-tools@1.1.2
thebakery:ipgeocoder@0.1.2
themeteorchef:bert@2.1.3
tmeasday:check-npm-versions@0.3.1
tracker@1.1.3

View file

@ -0,0 +1,17 @@
import { Meteor } from 'meteor/meteor';
// https://atmospherejs.com/thebakery/ipgeocoder
Meteor.startup(function(){
IPGeocoder.load();
});
Meteor.methods({
geo: function() {
// https://stackoverflow.com/questions/14843232/how-to-get-the-user-ip-address-in-meteor-server/22657421#22657421
clientIP = this.connection.clientAddress;
console.log(clientIP);
var geoData = IPGeocoder.geocode('82.124.236.10');
console.log(JSON.stringify(geoData));
return geoData;
}
});

View file

@ -2,3 +2,4 @@ import './accounts';
import './api';
import './fixtures';
import './email';
import './geolocation';