Comparing version 0.0.14 to 1.0.0
@@ -14,4 +14,4 @@ var util = require('util'), | ||
'ResponseGroup': 'ItemAttributes,Offers' | ||
}, function(results) { | ||
}, function(err, results) { | ||
console.log(results); | ||
}); |
@@ -60,6 +60,6 @@ var RSH = require('./RequestSignatureHelper').RequestSignatureHelper, | ||
OperationHelper.prototype.execute = function(operation, params, callback, onError) { | ||
OperationHelper.prototype.execute = function(operation, params, callback) { | ||
if (typeof(operation) === 'undefined') { throw 'Missing operation parameter' } | ||
if (typeof(params) === 'undefined') { params = {} } | ||
if (typeof(onError) === 'undefined') { onError = function(err){ console.log(err.message)}; } | ||
var uri = this.generateUri(operation, params); | ||
@@ -86,4 +86,3 @@ var host = this.endPoint; | ||
xml2js.parseString(responseBody, xml2jsOptions, function(err, result){ | ||
if (err) {onError(err);} | ||
callback(result, responseBody); | ||
callback(err, result, responseBody); | ||
}); | ||
@@ -95,3 +94,3 @@ }); | ||
request.on('error', function (err) { | ||
onError(err.message); | ||
callback(err); | ||
}); | ||
@@ -98,0 +97,0 @@ |
{ | ||
"name": "apac", | ||
"description": "Amazon Product Advertising API Client for Node", | ||
"version": "0.0.14", | ||
"version": "1.0.0", | ||
"author": "Dustin McQuay <dmcquay@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -7,2 +7,7 @@ # node-apac - Node.js client for the Amazon Product Advertising API. | ||
## Changelog | ||
**v1.0.0** | ||
Errors are now returned as the first parameter of the callback function, instead of being processed by a seperate OnError function. | ||
Note: This will break backwards compatibility with previous implementations where errors are processed by a sepearte funciton. Because of this, **version 1.0.0 will not be uploaded to NPM yet**, until more core features are added. Those who would like the new error processing implementation can get the module by cloning GitHub. | ||
## Installation | ||
@@ -33,7 +38,6 @@ | ||
// execute(operation, params, callback, onError) | ||
// execute(operation, params, callback) | ||
// operation: select from http://docs.aws.amazon.com/AWSECommerceService/latest/DG/SummaryofA2SOperations.html | ||
// params: parameters for operation (optional) | ||
// callback(parsed, raw): callback function handling results. parsed = xml2js parsed response. raw = raw xml response | ||
// onError: function handling errors, otherwise all error messages are printed with console.log() | ||
// callback(err, parsed, raw): callback function handling results. err = potential errors raised from xml2js.parseString() or http.request(). parsed = xml2js parsed response. raw = raw xml response. | ||
@@ -44,3 +48,3 @@ opHelper.execute('ItemSearch', { | ||
'ResponseGroup': 'ItemAttributes,Offers' | ||
}, function(results) { // you can add a second parameter here to examine the raw xml response | ||
}, function(err, results) { // you can add a third parameter for the raw xml response, "results" here are currently parsed using xml2js | ||
console.log(results); | ||
@@ -58,2 +62,10 @@ }); | ||
Error Handling: | ||
Note that there are three possible types of errors that can arise from opHelper.execute(). | ||
1: xml2js.parseString() raised an error. | ||
2: http.request to Amazon raised an error. (ex. a 404 error) | ||
3: An error returned by Amazon after successfully sending the request. (ex. You provided invalid AWS keys.) | ||
Both error 1 and 2 are returned as the first parameter to the callback funciton in v1.0.0, and error 3 would be in "results" as you successfully recieved a response from Amazon. | ||
## API Documentation | ||
@@ -60,0 +72,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
17102
1
97
253