Skip to content

Commit

Permalink
Add request parameter to API
Browse files Browse the repository at this point in the history
  • Loading branch information
piatra committed Apr 3, 2014
1 parent caf8bcd commit b4a77a8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions dashboard/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,23 @@
App.DEBUG = false;

// get wrapper, logs and calls the callback or fail fn
App.utils.httpGet = function httpGet(url, success, fail, always) {
App.utils.httpGet = function httpGet(url, params, success, fail) {
if (App.DEBUG) {
console.log('[GET] ' + url);
}
return $.get(url).done(success).fail(fail || displayFailMessage);
if (typeof params === 'function') {
params = {};
success = arguments[1];
fail = arguments[2];
} else {
if (App.DEBUG) {
console.log('[GET] params: ', params);
}
}
if (!success) {
console.error('[GET] no success handler supplied');
}
return $.get(url, params || {}).done(success).fail(fail || displayFailMessage);
};

App.Router = Backbone.Router.extend({
Expand Down Expand Up @@ -214,7 +226,7 @@
function checkForRepo(user, repo, fn) {
var url = App.HOST + '/available_repos';
var s = user + '/' + repo;
App.utils.httpGet(url, function(data) {
App.utils.httpGet(url, {name: 'andrei'}, function(data) {
var r = data.data.some(function(repo) {
return repo.match(s);
});
Expand Down

0 comments on commit b4a77a8

Please sign in to comment.