From d6300cda9b72e1a7881618ee4930710cccea9ce5 Mon Sep 17 00:00:00 2001 From: Ishaan Bahal Date: Thu, 8 Oct 2015 16:12:17 +0530 Subject: [PATCH 1/2] Handled error on get and post requests --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 4cc82d0..5215294 100644 --- a/index.js +++ b/index.js @@ -6,9 +6,9 @@ var DataDog = function(apiKey, applicationKey, opt_apiBaseUrl) { } this.apiBaseUrl = opt_apiBaseUrl; - this.apiKey = apiKey; this.applicationKey = applicationKey; + }; DataDog.prototype.postEvent = function(event, callback) { @@ -20,10 +20,10 @@ DataDog.prototype.postEvent = function(event, callback) { }, json: event }, - callback); + callback).on('error', function(e) { + console.log(e.message); }; - DataDog.prototype.postSeries = function(series, callback) { request.post({ url: this.apiBaseUrl + '/api/v1/series', @@ -33,10 +33,10 @@ DataDog.prototype.postSeries = function(series, callback) { }, json: series }, - callback); + callback).on('error', function(e) { + console.log(e.message); }; - DataDog.prototype.search = function(queryString, callback) { request.get({ url: this.apiBaseUrl + '/api/v1/search?q=' + queryString, @@ -45,8 +45,8 @@ DataDog.prototype.search = function(queryString, callback) { application_key: this.applicationKey } }, - callback); + callback).on('error', function(e) { + console.log(e.message); }; - module.exports = DataDog; From 9e0e3c29b8d4db8abbeb4ebdd06f368e517b8215 Mon Sep 17 00:00:00 2001 From: Ishaan Bahal Date: Thu, 8 Oct 2015 17:08:52 +0530 Subject: [PATCH 2/2] Handled error on get and post requests --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5215294..5354f54 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ var DataDog = function(apiKey, applicationKey, opt_apiBaseUrl) { this.apiBaseUrl = opt_apiBaseUrl; this.apiKey = apiKey; this.applicationKey = applicationKey; - + }; DataDog.prototype.postEvent = function(event, callback) { @@ -22,7 +22,7 @@ DataDog.prototype.postEvent = function(event, callback) { }, callback).on('error', function(e) { console.log(e.message); -}; +}); DataDog.prototype.postSeries = function(series, callback) { request.post({ @@ -35,7 +35,7 @@ DataDog.prototype.postSeries = function(series, callback) { }, callback).on('error', function(e) { console.log(e.message); -}; +}); DataDog.prototype.search = function(queryString, callback) { request.get({ @@ -47,6 +47,6 @@ DataDog.prototype.search = function(queryString, callback) { }, callback).on('error', function(e) { console.log(e.message); -}; +}); module.exports = DataDog;