调用方法传递结果异常

Exception in delivering result of invoking method

我一直在使用 meteor 测试 http 调用,我使用了 nitrous(因为周末我无法访问我的开发笔记本电脑)并且它运行良好。 但是当我尝试从本地电脑 运行 时,它 returns:

Exception in delivering result of invoking 'getMatch': TypeError: Cannot read property 'duration' of undefined.

任何关于可能是什么原因的想法? 方法定义:

Dota = {};

Dota.getMatch = function() {
    if (!Meteor.settings.steamToken)
    throw new Meteor.Error(500, 'Enter a valid Steam Token in Meteor.settings');

    var matchResponse = Meteor.http.get(
       "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?",
        {
            params:{
                "match_id": "1305454585",
                "key": Meteor.settings.steamToken
            }
        }
    );

    if (matchResponse.statusCode === 200) {
        return matchResponse.data.result
    }
    else {
        throw new Meteor.Error(500, "getMatch failed with error: "+matchResponse.statusCode);
    }
}

Meteor.methods({
    'getMatch': function(){
        return Dota.getMatch();
    }
})

调用方法:

Meteor.call('getMatch', function(error, result){
    var duration = numeral(result.duration).format('00:00:00');
    Session.set('duration', duration);

    var winner = Meteor.myFunctions.getWinner(result.radiant_win);
    Session.set('winner', winner);
});

Template.layout.helpers({
    winner: function () {
        return Session.get('winner');
    },
    duration: function () {
        return Session.get('duration');
    }
});

找到解决办法,我换了位置

Meteor.methods({
    'getMatch': function(){
        return Dota.getMatch();
    }
})

到 server/server.js(我在 packages/dota/dota.js 中有它)现在它可以工作了!感谢@user3374348 的帮助!