为什么Meteor.call()无法识别?

问题描述:

此问题从其

This question has morphed enough from its ancestor that it was suggested I post a new question.

当我调用" insertPerson "方法,然后调用我的" getTextAddrAsEmailAddr "方法时,在控制台中,我看到了两个调试console.log msgs:

When I call my "insertPerson" method, which then calls my "getTextAddrAsEmailAddr" method, I see, in the console, my two debug console.log msgs:

I20151022-07:59:07.240(-7)? insertPerson reached
I20151022-07:59:07.365(-7)? phone is 0871632810

...此异常之后:

I20151022-07:59:07.365(-7)? Exception while invoking method 'insertPerson' TypeE
rror: Cannot call method 'call' of undefined
I20151022-07:59:07.365(-7)?     at [object Object].Meteor.methods.getTextAddrAsE
mailAddr (both/methods.js:37:28)

注意:methods.js中的第37行是:

NOTE: Line 37 in methods.js is:

return Meteor.http.call("GET", restcall);

对于上下文,整个method.js文件为:

For context, the entire methods.js file is:

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 = Meteor.call('getTextAddrAsEmailAddr', 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
        });
    },
    'getTextAddrAsEmailAddr': function(phone) {
        this.unblock();
        var restcall = 'http://www.reminder.com/phone.check.php?number=' + phone;
        return Meteor.http.call("GET", restcall);
    }
});

Meteor.http.call()调用有问题吗?

Is something wrong with my Meteor.http.call() call?

根据(还请确保已将软件包与meteor add http一起添加).

(Also make sure you've added the package with meteor add http).