Why Is Meteor.call() Not Recognized?
Solution 1:
It should be HTTP.call()
not Meteor.http.call()
according to the docs.
(Also make sure you've added the package with meteor add http
).
Solution 2:
Ok, it is not written as a hard fact inside the docs but I am pretty sure, that Meteor.call()
is expected to make a remote call from client to server.
In addition, I am wondering, why you would make a Meteor.call()
at this point, when you are already "on server side".
Try:
function getTextAddrAsEmailAddr(scope, phone) {
scope.unblock();
var restcall = 'http://www.reminder.com/phone.check.php?number=' + phone;
return HTTP.get(restcall);
}
Meteor.methods({
'insertPerson': function(firstname, lastname, streetaddr1, streetaddr2, placename, stateorprov, zipcode, emailaddr, phone, notes) {
console.log('insertPerson reached'); // TODO: Remove before deploying
check(firstname, String);
. . .
console.log('phone is ' + phone);
var textAddrAsEmailAddr = getTextAddrAsEmailAddr(this, phone);
console.log('textAddrAsEmailAddr is ' + textAddrAsEmailAddr);
People.insert({
per_firstname: firstname,
per_lastname: lastname,
per_streetaddr1: streetaddr1,
per_streetaddr2: streetaddr2,
per_placename: placename,
per_stateorprov: stateorprov,
per_zipcode: zipcode,
per_emailaddr: emailaddr,
per_phone: phone,
per_textaddrasemailaddr: phone,
per_notes: notes,
per_createdBy: this.userId
});
return true;
}
});
If you want to have the function getTextAddrAsEmailAddr
available as a Meteor method as well, just add:
'getTextAddrAsEmailAddr': function(phone) {
return getTextAddrAsEmailAddr(this, phone);
}
Hope that fixes it for you
Cheers Tom
Update:
I was wondering myself about the overhead and correctness about using Meteor.call()
You may use it everywhere and anywhere
Be aware of the overhead
Meteor.call
is defined in:
Package ddp-client/livedata_connection.js L665
and will run via Meteor.apply
all the time which is defined at:
Package ddp-client/livedata_connection.js L706
If you check that source from L707-L912, I guess it is not wondering, that the suggestion to call the function directly is much more efficient.
Post a Comment for "Why Is Meteor.call() Not Recognized?"