Permalink
Browse files

Move query objects out of path, Fixes #76

  • Loading branch information...
1 parent fe1ce37 commit 3df282d73a57f2a268a56174b7c2bf08f29a8fcc @pksunkara committed Dec 8, 2013
Showing with 33 additions and 29 deletions.
  1. +4 −4 README.md
  2. +11 −6 lib/octonode/repo.js
  3. +7 −7 lib/octonode/search.js
  4. +4 −5 src/octonode/repo.coffee
  5. +7 −7 src/octonode/search.coffee
View
@@ -31,7 +31,7 @@ var ghsearch = client.search();
```js
var client = github.client();
-client.get('/users/pksunkara', function (err, status, body) {
+client.get('/users/pksunkara', {}, function (err, status, body, headers) {
console.log(body); //json object
});
```
@@ -41,7 +41,7 @@ client.get('/users/pksunkara', function (err, status, body) {
```js
var client = github.client('someaccesstoken');
-client.get('/user', function (err, status, body) {
+client.get('/user', {}, function (err, status, body, headers) {
console.log(body); //json object
});
```
@@ -54,7 +54,7 @@ var client = github.client({
password: 'password'
});
-client.get('/user', function (err, status, body) {
+client.get('/user', {}, function (err, status, body, headers) {
console.log(body); //json object
});
```
@@ -67,7 +67,7 @@ var client = github.client({
secret: 'abcdefghijk'
});
-client.get('/user', function (err, status, body) {
+client.get('/user', {}, function (err, status, body, headers) {
console.log(body); //json object
});
```
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -121,7 +121,7 @@ class Repo
if !cb? and cbOrRef
cb = cbOrRef
cbOrRef = 'master'
- @client.get "/repos/#{@name}/readme?ref=#{cbOrRef}", (err, s, b, h) ->
+ @client.get "/repos/#{@name}/readme", {ref: cbOrRef}, (err, s, b, h) ->
return cb(err) if err
if s isnt 200 then cb(new Error("Repo readme error")) else cb null, b, h
@@ -131,7 +131,7 @@ class Repo
if !cb? and cbOrRef
cb = cbOrRef
cbOrRef = 'master'
- @client.get "/repos/#{@name}/contents/#{path}?ref=#{cbOrRef}", (err, s, b, h) ->
+ @client.get "/repos/#{@name}/contents/#{path}", {ref: cbOrRef}, (err, s, b, h) ->
return cb(err) if err
if s isnt 200 then cb(new Error("Repo contents error")) else cb null, b, h
@@ -168,9 +168,8 @@ class Repo
if !cb? and cbOrRecursive
cb = cbOrRecursive
cbOrRecursive = false
- url = "/repos/#{@name}/git/trees/#{sha}"
- url += "?recursive=1" if cbOrRecursive
- @client.get url, (err, s, b, h) ->
+ param = {recursive: 1} if cbOrRecursive
+ @client.get "/repos/#{@name}/git/trees/#{sha}", param, (err, s, b, h) ->
return cb(err) if err
if s isnt 200 then cb(new Error("Repo tree error")) else cb null, b, h
View
@@ -20,20 +20,20 @@ class Search
# Search repositories
repos: (keyword, language, start_page, cb) ->
- param = ''
- param+= "language=#{language}&" if language
- param+= "start_page=#{start_page}&" if start_page
+ param = {}
+ param['language'] = language if language
+ param['start_page'] = start_page if start_page
- @client.get "/legacy/repos/search/#{keyword}?#{param}", (err, s, b, h) ->
+ @client.get "/legacy/repos/search/#{keyword}", param, (err, s, b, h) ->
return cb(err) if err
if s isnt 200 then cb(new Error('Search repos error')) else cb null, b.repositories, h
# Search users
users: (keyword, start_page, cb) ->
- param = ''
- param+= "start_page=#{start_page}&" if start_page
+ param = {}
+ param['start_page'] = start_page if start_page
- @client.get "/legacy/user/search/#{keyword}?#{param}", (err, s, b, h) ->
+ @client.get "/legacy/user/search/#{keyword}", param, (err, s, b, h) ->
return cb(err) if err
if s isnt 200 then cb(new Error('Search users error')) else cb null, b.users, h

0 comments on commit 3df282d

Please sign in to comment.