During my time using Meteor 1.2, I utilized the following code on my server to access user data and friends data:
function Facebook(accessToken) {
this.fb = Meteor.npmRequire('fbgraph');
this.accessToken = accessToken;
this.fb.setAccessToken(this.accessToken);
this.options = {
timeout: 3000,
pool: {maxSockets: Infinity},
headers: {connection: "keep-alive"}
}
this.fb.setOptions(this.options);
}
Facebook.prototype.query = function(query, method) {
var self = this;
var method = (typeof method === 'undefined') ? 'get' : method;
var data = Meteor.sync(function(done) {
self.fb[method](query, function(err, res) {
done(null, res);
});
});
return data.result;
}
Facebook.prototype.getUserData = function() {
return this.query('me');
}
Facebook.prototype.getFriendsData = function() {
return this.query('/me/friends');
}
When upgrading my project to Meteor 1.3, I used "meteor npm install --save fbgraph" to include fbgraph but discovered that 'npmRequire' was no longer functional, so I replaced it with 'require' like this:
function Facebook(accessToken) {
this.fb = require('fbgraph');
this.accessToken = accessToken;
this.fb.setAccessToken(this.accessToken);
this.options = {
timeout: 3000,
pool: {maxSockets: Infinity},
headers: {connection: "keep-alive"}
}
this.fb.setOptions(this.options);
}
Despite these changes, I still encountered an error: Exception while invoking method 'getFriendsData' TypeError: Object [object Object] has no method 'sync'
Therefore, I am inquiring whether there is a similar function to 'Meteor.sync' from Meteor 1.2 available in Meteor 1.3. If not, what adjustments should be made to the fb querying code to ensure compatibility with Meteor 1.3.