philschatz / octokat.js

:octocat: Github API Client using Promises or callbacks. Intended for the browser or NodeJS.
http://philschatz.com/2014/05/25/octokat/
MIT License
421 stars 133 forks source link

Error with parsed json returned by gists #29

Closed gmaclennan closed 9 years ago

gmaclennan commented 9 years ago

octo.gists(gist_id).fetch() returns incorrectly parsed json for data.files:

{
raw: 
      { [Function]
        url: 'https://gist.githubusercontent.com/..../file.txt' },
}

This should be raw_url but it looks like somehow it is getting parsed. read() returns the correct unparsed json string.

gmaclennan commented 9 years ago

Here's a failing test:

https://github.com/gmaclennan/octokat.js/blob/gist-raw_url-test/test/ruby-specs/gists.spec.coffee#L112

Sorry I don't really know chai, but raw_url should be a url, but it is undefined.

philschatz commented 9 years ago

Thanks! You should be able to use raw.url instead of raw_url. This conversion is a result of adding support for GitHub's Hypermedia (details in the Repo Readme).

There should probably be an option for turning off the JSON conversion in future versions of this client.

gmaclennan commented 9 years ago

Aha! I had missed that part of the readme. It makes sense now.