Skip to content

Commit

Permalink
with access to api request
Browse files Browse the repository at this point in the history
expose the call to request methods so that they can be aborted.
  • Loading branch information
apostopher committed Jul 6, 2015
1 parent fadbdd4 commit abd3e1a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/graph.js
Expand Up @@ -72,7 +72,7 @@ function Graph(method, url, postData, callback) {
this.options.uri = url;
this.options.followRedirect = false;

this[method.toLowerCase()]();
this.request = this[method.toLowerCase()]();

return this;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ Graph.prototype.end = function (body) {
Graph.prototype.get = function () {
var self = this;

request.get(this.options, function(err, res, body) {
return request.get(this.options, function(err, res, body) {
if (err) {
self.callback({
message: 'Error processing https request'
Expand Down Expand Up @@ -211,7 +211,7 @@ Graph.prototype.post = function() {

this.options.body = postData;

request(this.options, function (err, res, body) {
return request(this.options, function (err, res, body) {
if (err) {
self.callback({
message: 'Error processing https request'
Expand Down Expand Up @@ -326,7 +326,7 @@ exports.del = function (url, postData, callback) {
postData = url.indexOf('access_token') !== -1 ? {} : {access_token: accessToken};
}

this.post(url, postData, callback);
return this.post(url, postData, callback);
};


Expand All @@ -345,7 +345,7 @@ exports.search = function (options, callback) {

/**
* Perform a batch query on the graph api
*
*
* @param {Array} reqs An array containing queries
* @param {[Object]} additionalData Additional data to send, e.g. attachments or the `include_headers` parameter.
* @param {Function} callback
Expand Down Expand Up @@ -426,7 +426,7 @@ exports.getOauthUrl = function (params, opts) {
exports.authorize = function (params, callback) {
var self = this;

this.get("/oauth/access_token", params, function(err, res) {
return this.get("/oauth/access_token", params, function(err, res) {
if (!err) self.setAccessToken(res.access_token);

callback(err, res);
Expand All @@ -449,7 +449,7 @@ exports.extendAccessToken = function (params, callback) {
params.grant_type = 'fb_exchange_token';
params.fb_exchange_token = params.access_token ? params.access_token : this.getAccessToken();

this.get("/oauth/access_token", params, function(err, res) {
return this.get("/oauth/access_token", params, function(err, res) {
if (!err && !params.access_token) {
self.setAccessToken(res.access_token);
}
Expand Down Expand Up @@ -498,8 +498,8 @@ exports.getAccessToken = function () {
};

/**
* Set's the Graph API version.
* Note that you don't need to specify the 'v', just
* Set's the Graph API version.
* Note that you don't need to specify the 'v', just
* add '2.1', '1.1' etc
* @param {string} version
*/
Expand Down

0 comments on commit abd3e1a

Please sign in to comment.