I am really struggling with Meteor and the NPM package node-linkedin.
I understand how NPM integration is supposed to work. I added NPM using Meteorite and node-linkedin to packages.js. I am then calling the NPM package through Meteor.require().
Here is my server/linkedin.js file:
function Linkedin(accessToken) {
this.linkedin = Meteor.require('node-linkedin')('api', 'secret', 'callback');
this.accessToken = accessToken;
this.linkedin.init(this.accessToken);
}
Linkedin.prototype.company = function() {
var self = this;
var data = Meteor.sync(function(done) {
self.linkedin.companies.company('162479', function(err, res) {
done(null, res);
});
});
return data.result;
}
Meteor.methods({
getCompanyInfo: function () {
var linkedin = new Linkedin(Meteor.user().services.linkedin.accessToken);
var data = linkedin.company();
return data;
}
});
Unfortunately, it does not work when I call getCompanyInfo()... I get the following error: "Cannot call method 'company' of undefined".
Linkedin Auth works fine (thanks to accounts-linkedin). But I also need to connect to Linkedin API.
I had previously followed this article to play with FB Graph API in Meteor. Everything was fine.
Maybe the problem comes from Metheor.require(). I am wondering what I am supposed to do with the second set of parameters in Metheor.require(). Should I add these npm packages to packages.json as well? Does Method.require() handle this second set of parameters correctly?
Thank you for your help!