Skip to content

Instantly share code, notes, and snippets.

@uzair004
Created March 21, 2023 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzair004/ac82e5f5c9ea4e87e0d1a0380721e840 to your computer and use it in GitHub Desktop.
Save uzair004/ac82e5f5c9ea4e87e0d1a0380721e840 to your computer and use it in GitHub Desktop.
push to sqs queue using nodejs
const AWS = require("aws-sdk");
// api key etc will be take from .env
AWS.config.update({ region: process.env.AWS_REGION });
const sqs = new AWS.SQS({ apiVersion: "2012-11-05" });
const pushToQueue = (message) => {
return new Promise((resolve, reject) => {
sqs.sendMessage(
{
MessageBody: JSON.stringify(message),
QueueUrl: process.env.RES_QUEUE_ENDPOINT,
},
function (err, data) {
if (err) reject(err);
else if (data) resolve(data);
}
);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment