Skip to content
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
9 changes: 6 additions & 3 deletions src/BookSearchApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ function BookSearchApiClient(format) {
this.format = format;
}

BookSearchApiClient.prototype.getBooksByAuthor = function (authorName, limit) {
BookSearchApiClient.prototype.getBooksByQuery = function (url, queryName, queryValue, limit) {
var result = [];
var xhr = new XMLHttpRequest();
xhr.open(
"GET",
"http://api.book-seller-example.com/by-author?q=" +
authorName +
url +
queryName +
queryValue +
"&limit=" +
limit +
"&format=" +
Expand All @@ -33,6 +34,8 @@ BookSearchApiClient.prototype.getBooksByAuthor = function (authorName, limit) {
var xml = xhr.responseXML;

result = xml.documentElement.childNodes.map(function (item) {
//create list of Books from Book class; populate individual objects' field and return the list.
//Do not know how to do it in Javascript as I am a Java programmer.
return {
title: item.childNodes[0].childNodes[0].nodeValue,
author: item.childNodes[0].childNodes[1].nodeValue,
Expand Down