Skip to content

Instantly share code, notes, and snippets.

@dance2die
Created June 19, 2017 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/251e12bf0bb6f27c955d9f93ca50cf19 to your computer and use it in GitHub Desktop.
Save dance2die/251e12bf0bb6f27c955d9f93ca50cf19 to your computer and use it in GitHub Desktop.
firstAttempt()
export default class DemoMain {
constructor() {
this.goodReadsURL = `https://www.goodreads.com/shelf/list.xml`;
this.q = `key=${apiConfig.goodreadsKey}&user_id=${apiConfig.goodreadsUserID}&page=1`;
this.url = `${this.goodReadsURL}?${this.q}`;
}
logResult(url) {
axios.get(url, { params: { format: "json" } })
.then((yqlResponse) => {
let data = yqlResponse.data;
// DefiantJS XPath query for user shelf for "read" section.
let search = JSON.search(data, "//*/user_shelf[name='read']");
console.log(search);
}).catch((error) => {
alert(`error: ${error}`);
});
}
firstAttempt() {
this.logResult(this.url);
}
}
var demo = new DemoMain();
demo.firstAttempt();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment