google-books-search-2
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -14,16 +14,16 @@ /** | ||
var defaultOptions = { | ||
// Google API key | ||
key: null, | ||
// Search in a specified field | ||
field: null, | ||
// The position in the collection at which to start the list of results (startIndex) | ||
offset: 0, | ||
// The maximum number of elements to return with this request (Max 40) (maxResults) | ||
limit: 10, | ||
// Restrict results to books or magazines (or both) (printType) | ||
type: 'all', | ||
// Order results by relevance or newest (orderBy) | ||
order: 'relevance', | ||
// Restrict results to a specified language (two-letter ISO-639-1 code) (langRestrict) | ||
lang: 'en' | ||
// Google API key | ||
key: null, | ||
// Search in a specified field | ||
field: null, | ||
// The position in the collection at which to start the list of results (startIndex) | ||
offset: 0, | ||
// The maximum number of elements to return with this request (Max 40) (maxResults) | ||
limit: 10, | ||
// Restrict results to books or magazines (or both) (printType) | ||
type: 'all', | ||
// Order results by relevance or newest (orderBy) | ||
order: 'relevance', | ||
// Restrict results to a specified language (two-letter ISO-639-1 code) (langRestrict) | ||
lang: 'en' | ||
}; | ||
@@ -33,7 +33,7 @@ | ||
var fields = { | ||
title: 'intitle:', | ||
author: 'inauthor:', | ||
publisher: 'inpublisher:', | ||
subject: 'subject:', | ||
isbn: 'isbn:' | ||
title: 'intitle:', | ||
author: 'inauthor:', | ||
publisher: 'inpublisher:', | ||
subject: 'subject:', | ||
isbn: 'isbn:' | ||
}; | ||
@@ -46,3 +46,3 @@ | ||
* Search Google Books | ||
* | ||
* | ||
* @param {String} query Search term | ||
@@ -74,21 +74,22 @@ * @param {Object} options Search options | ||
return new Promise(function(resolve, reject) { | ||
var options = extend(defaultOptions, options || {}); | ||
var options = extend(defaultOptions, options || {}); | ||
// Create the request uri | ||
var query = { | ||
q: query, | ||
startIndex: options.offset, | ||
maxResults: options.limit, | ||
printType: options.type, | ||
orderBy: options.order, | ||
langRestrict: options.lang | ||
}; | ||
// Create the request uri | ||
var queryUrl = { | ||
q: query, | ||
startIndex: options.offset, | ||
maxResults: options.limit, | ||
printType: options.type, | ||
orderBy: options.order, | ||
langRestrict: options.lang | ||
}; | ||
if (options.key) { | ||
query.key = options.key; | ||
} | ||
if (options.key) { | ||
queryUrl.key = options.key; | ||
} | ||
var uri = baseUrl + querystring.stringify(query); | ||
var uri = baseUrl + querystring.stringify(queryUrl); | ||
return new Promise(function(resolve, reject) { | ||
// Send Request | ||
@@ -95,0 +96,0 @@ https.get(uri, function(response){ |
{ | ||
"name": "google-books-search-2", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "A node wrapper for the Google Books API. Based on the original project google-books-search.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/google-books-search.js", |
Sorry, the diff of this file is not supported yet
24977