Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Error Catch

Adds callback with error when errors happened before the end event. Removes superfluous port option. Version bump.
  • Loading branch information...
commit bbb4491bdf5148f145d1a4a53666728691c5034b 1 parent 9273e3e
Jamie Hoover ⚔ authored
Showing with 4 additions and 3 deletions.
  1. +3 −2 lib/yummly.js
  2. +1 −1  package.json
View
5 lib/yummly.js
@@ -13,7 +13,6 @@ function getJSON(options, callback) {
http.get({
host: options.host || 'api.yummly.com',
path: (options.root || '/v1/api/') + options.path,
- port: options.port || 80,
headers: options.headers || {
'Content-Type': 'application/json',
'X-Yummly-App-ID': options.credentials.id,
@@ -22,7 +21,9 @@ function getJSON(options, callback) {
}, function (response) {
var json = '';
- response.on('data', function (data) {
+ response.on('error', function (error) {
+ callback(error);
+ }).on('data', function (data) {
json += data;
}).on('end', function (error) {
callback(error, response.statusCode, JSON.parse(json));
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "yummly",
- "version": "0.2.3",
+ "version": "0.2.4",
"description": "Yummly API Module",
"homepage": "https://github.com/yummly/node-yummly/",
Please sign in to comment.
Something went wrong with that request. Please try again.