Closed picsoung closed 9 years ago
Mmm, weird there's an error and it still works :> What Meteor version are you using and where are you using this (method or publish?), and if you're inside an anonymous function, did you store self = this
?
Also since Meteor 0.7.1, you can use this.connection.clientAddress
.
I am using Meteor 0.8.1.1 (latest).
the code is
Meteor.methods({
validateCaptcha: function(){
var self = this;
var ip = self.connection.clientAddress;
//headers.methodClientIP(self);
console.log("IP",ip);
}
});
Both work but still throwing an error...
I believe your error occurs cause the reference to this is lost inside the visualcaptcha method. Try this:
Meteor.methods({
var self = this;
validateCaptcha: function(){
var ip = self.connection.clientAddress;
//headers.methodClientIP(self);
console.log("IP",ip);
}
})
Oops sorry, this thread fell through the cracks a bit.
@picsoung, hope you got this working by now, sorry :) But if you still got an error even with the self.connection.clientAddress
line, then the error isn't from the headers
package, because you aren't using it there. It's very weird, did you figure it out?
@scorpwarp23, Meteor.methods
accepts a key-value dictionary... it's not passed a function and unfortunately you can't put JavaScript in the middle of the object declaration. I don't think the self scope was the problem though.
Hi,
I am trying to use the new
methodClientIP
in aMeteor.method
but I got a errorTypeError: undefined is not a function
on the particular lineBut when I print
ip
I have the correct localhost IP. Anyway I could avoid this error ? thanks