Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Callback should use the more proper signature of (err, msg), fixes #3

Also updated documentation and examples
commit 2cf64d0fa54b3b2cf0b898529f3b19f9e0a8dfa8 1 parent e6c1c49
@mattrobenolt authored
View
11 README.md
@@ -1,4 +1,7 @@
# Amazon AWS SNS (Simple Notification Service) http(s) endpoint
+## **Important API Change from v0.1 to v0.2**
+The main `SNSClient` callback now returns the more accepted Node.js method of `function(err, msg)`. v0.1 sent both the error and message as a single argument.
+
## Installation
```
$ npm install aws-snsclient
@@ -9,7 +12,7 @@ $ npm install aws-snsclient
var http = require('http')
, SNSClient = require('aws-snsclient');
-var client = SNSClient(function(message) {
+var client = SNSClient(function(err, message) {
console.log(message);
});
@@ -38,7 +41,7 @@ Signatures are automatically verified, but we can optionally verify the correct
var auth = {
verify: false
};
-var client = SNSClient(auth, function(message) {
+var client = SNSClient(auth, function(err, message) {
console.log(message);
});
```
@@ -50,7 +53,7 @@ var auth = {
, account: 'xxx'
, topic: 'xxx'
};
-var client = SNSClient(auth, function(message) {
+var client = SNSClient(auth, function(err, message) {
console.log(message);
});
```
@@ -66,7 +69,7 @@ var auth = {
, account: 'xxx'
, topic: 'xxx'
}
-var client = SNSClient(auth, function(message) {
+var client = SNSClient(auth, function(err, message) {
console.log(message);
});
View
5 examples/express.js
@@ -7,7 +7,10 @@ var auth = {
, account: 'xxx'
, topic: 'topic-name'
}
-var client = SNSClient(auth, function(message) {
+var client = SNSClient(auth, function(err, message) {
+ if (err) {
+ throw err;
+ }
console.log(message);
});
View
5 examples/raw.js
@@ -6,7 +6,10 @@ var auth = {
, account: 'xxx'
, topic: 'xxx'
}
-var client = SNSClient(auth, function(message) {
+var client = SNSClient(auth, function(err, message) {
+ if (err) {
+ throw err;
+ }
console.log(message);
});
View
2  lib/snsclient.js
@@ -125,7 +125,7 @@ function SNSClient(opts, cb) {
return https.get(url.parse(message.SubscribeURL));
}
if(message.Type === 'Notification') {
- return cb(message);
+ return cb(null, message);
}
});
});

0 comments on commit 2cf64d0

Please sign in to comment.
Something went wrong with that request. Please try again.