javascript - MeteorJs - Error in an http call -
this first meteor program , i'm trying make http call github. i'm facing error goes this:
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 ._maybeinvokecallback@http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3860:7 .receiveresult@http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3880:5 ._livedata_result@http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:4964:7 connection/onmessage@http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:3725:7 ._launchconnection/self.socket.onmessage/<@http://localhost:3000/packages/ddp.js?d1840d3ba04c65ffade261f362e26699b7509706:2717:11 _.foreach@http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:7 ._launchconnection/self.socket.onmessage@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
here code:
if (meteor.isclient) { // counter starts @ 0 session.setdefault('counter', 0); template.hello.helpers({ counter: function () { return session.get('counter'); } }); //this how bind event handlers //format: eventtype selector template.hello.events({ 'click button': function () { // increment counter when button 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 run on server @ 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; } }); //}); }
i using github api javascript wrapper. if try make call using simple http, still error.
what needs done solve this?
update here server log:
exception while invoking method 'getuserinfo' referenceerror: github not defined i20150429-19:22:53.064(5.5)? @ [object object].meteor.methods.getuserinfo (app/hellometeor.js:29:34) i20150429-19:22:53.064(5.5)? @ maybeauditargumentchecks (packages/ddp/livedata_server.js:1617:1) i20150429-19:22:53.064(5.5)? @ packages/ddp/livedata_server.js:648:1 i20150429-19:22:53.064(5.5)? @ [object object]._.extend.withvalue (packages/meteor/dynamics_nodejs.js:56:1) i20150429-19:22:53.064(5.5)? @ packages/ddp/livedata_server.js:647:1 i20150429-19:22:53.064(5.5)? @ [object object]._.extend.withvalue (packages/meteor/dynamics_nodejs.js:56:1) i20150429-19:22:53.064(5.5)? @ [object object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1) i20150429-19:22:53.064(5.5)? @ packages/ddp/livedata_server.js:546:1
okay, advise install this lovely package:
meteor add bruz:github-api
it should allow use github api on server side, according example on web page linked to.
after-chat edit: far readme of package outdated. use package shown in example, need call instead of require("github")
:
npm.require('github-api');
then rest of example should fine. should make pull request ask update.
Comments
Post a Comment