-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (30 loc) · 817 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Load the AWS SDK for Node.js
var AWS = require("aws-sdk");
AWS.config.update({ region: "us-east-1" });
const payload = {
type: "SignupVerification",
data: {
email: "[email protected]",
verificationCode: "452178",
},
};
// Create publish parameters
var params = {
Message: JSON.stringify(payload) /* required */,
TopicArn: "TOPIC_ARN",
};
// Create promise and SNS service object
var publishTextPromise = new AWS.SNS({ apiVersion: "2010-03-31" })
.publish(params)
.promise();
// Handle promise's fulfilled/rejected states
publishTextPromise
.then(function (data) {
console.log(
`Message ${params.Message} sent to the topic ${params.TopicArn}`
);
console.log("MessageID is " + data.MessageId);
})
.catch(function (err) {
console.error(err, err.stack);
});