这是我的第一个流星计划,我正在尝试向Github发起http呼叫。我面临的是这样的一个错误:MeteorJs - http呼叫中的错误
Exception in delivering result of invoking 'getUserInfo': ["click button"]/<@http://localhost:3000/helloMeteor.js?823f404b37c246a7d23ae50a10c37969e426b2b8:18:17 Meteor.bindEnvironment/<@http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:983:17 [email protected]http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3860:7 [email protected]http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3880:5 [email protected]http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:4964:7 Connection/[email protected]http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3725:7 ._launchConnection/self.socket.onmessage/<@http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:2717:11 [email protected]http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:7 ._launchConnection/[email protected]http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:2716:9 SockJShttp://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:156:9 SockJShttp://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:1141:5 SockJShttp://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:1199:13 SockJShttp://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:1346:9
这里是我的代码:
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault('counter', 0);
Template.hello.helpers({
counter: function() {
return Session.get('counter');
}
});
//This is how you bind event handlers
//Format: eventtype selector
Template.hello.events({
'click button': function() {
// increment the counter when button is clicked
Session.set('counter', Session.get('counter') + 1);
Meteor.call('getUserInfo', 'rutwick', function(err, res) {
console.log(result);
});
}
});
}
if (Meteor.isServer) {
//Meteor.startup(function() {
// code to run on server at startup
Meteor.methods({
getUserInfo: function(userN) {
var github = new GitHub({
version: "3.0.0", // required
timeout: 5000 // optional
});
var result = github.user.getFollowingFromUser({
user: userN
});
return result;
}
});
//});
}
我使用Github的API JavaScript包装。即使我尝试使用简单的HTTP进行通话,我仍然会遇到错误。
究竟需要做些什么来解决这个问题?
更新 这里是服务器日志:
Exception while invoking method 'getUserInfo' ReferenceError: GitHub is not defined I20150429-19:22:53.064(5.5)? at [object Object].Meteor.methods.getUserInfo (app/helloMeteor.js:29:34) I20150429-19:22:53.064(5.5)? at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1) I20150429-19:22:53.064(5.5)? at packages/ddp/livedata_server.js:648:1 I20150429-19:22:53.064(5.5)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) I20150429-19:22:53.064(5.5)? at packages/ddp/livedata_server.js:647:1 I20150429-19:22:53.064(5.5)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) I20150429-19:22:53.064(5.5)? at [object Object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1) I20150429-19:22:53.064(5.5)? at packages/ddp/livedata_server.js:546:1
我们可以有Chrome控制台输出(它更好),如果它适用,服务器日志也是? – SylvainB
啊哈,服务器日志。我不知道有一个服务器日志。我发布的输出来自FireBug的控制台。用服务器日志更新我的问题。 –
不用担心:)只显示服务器日志,如果它适用。但我至少不能强调使用Chrome *至少*来查看控制台日志,其他控制台至少只是废话......对于流星来说。 – SylvainB