Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make `callback` optional.

  • Loading branch information...
commit 51f780b96bc6943e62b2f76f03702f5e0c1c7794 1 parent c2b6b38
@ryantenney ryantenney authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/notifo.js
View
14 lib/notifo.js
@@ -21,7 +21,7 @@ function Notifo(args) {
Notifo.prototype.send = function (options, callback) {
// Setup default values and light validation.
if (!options.title && !options.uri && !options.msg) {
- callback(new Error('Tried to send notification without any information.'), null);
+ callback && callback(new Error('Tried to send notification without any information.'), null);
return false;
}
@@ -31,7 +31,7 @@ Notifo.prototype.send = function (options, callback) {
});
if (!options.msg) {
- callback(new Error('Must supply a msg.'), null);
+ callback && callback(new Error('Must supply a msg.'), null);
return false;
}
@@ -51,12 +51,12 @@ Notifo.prototype.send = function (options, callback) {
try {
var response = JSON.parse(body.match(/{"status.*/)[0].trim());
if (response['response_code'] !== 2201) {
- callback(new Error('notifo code '+response['response_code']+': '+response['response_message']), response);
+ callback && callback(new Error('notifo code '+response['response_code']+': '+response['response_message']), response);
} else {
- callback(null, response);
+ callback && callback(null, response);
}
} catch(e) {
- callback(e, null);
+ callback && callback(e, null);
}
});
});
@@ -64,6 +64,6 @@ Notifo.prototype.send = function (options, callback) {
req.end();
req.on('error', function(e) {
- callback(e, null);
+ callback && callback(e, null);
});
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.