Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return request object #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
* @param cb {Function} the callback function to handle the response
*/
api = function() {
var req;
//
// FB.api('/platform', function(response) {
// console.log(response.company_overview);
Expand Down Expand Up @@ -129,10 +130,11 @@
//
//
if(typeof arguments[0] === 'string') {
graph.apply(this, arguments);
req = graph.apply(this, arguments);
} else {
rest.apply(this, arguments);
req = rest.apply(this, arguments);
}
return req;
};

/**
Expand Down Expand Up @@ -191,7 +193,7 @@
return;
}

oauthRequest('graph', path, method, params, cb);
return oauthRequest('graph', path, method, params, cb);
};

/**
Expand All @@ -206,7 +208,7 @@

params.format = 'json-strings';
var domain = readOnlyCalls[method] ? 'api_read' : 'api';
oauthRequest(domain, 'restserver.php', 'get', params, cb);
return oauthRequest(domain, 'restserver.php', 'get', params, cb);
};

/**
Expand All @@ -226,7 +228,8 @@
, key
, value
, requestOptions
, isOAuthRequest;
, isOAuthRequest
, req;

cb = cb || function() {};
if(!params.access_token && options('accessToken')) {
Expand Down Expand Up @@ -284,7 +287,7 @@
if(options('timeout')) {
requestOptions['timeout'] = options('timeout');
}
request(requestOptions
req = request(requestOptions
, function(error, response, body) {
if(error !== null) {
if(error === Object(error) && has(error, 'error')) {
Expand Down Expand Up @@ -312,6 +315,7 @@
cb(json);
}
});
return req;
};

parseOAuthApiResponse = function (body) {
Expand Down Expand Up @@ -519,7 +523,7 @@
args.push(typeof(originalCallback) == 'function' ? nodeifyCallback(originalCallback) : originalCallback);
}

api.apply(this, args);
return api.apply(this, args);
};

/**
Expand Down