Sometimes, we want to use async and await with Node.js AWS SDK.
In this article, we’ll look at how to use async and await with Node.js AWS SDK.
How to use async and await with Node.js AWS SDK?
To use async and await with Node.js AWS SDK, we can call the promise
method after we call the AWS SDK method.
For instance, we write
try {
const key = await kms.generateDataKey().promise();
} catch (e) {
console.log(e);
}
to call promise
after call generateDataKey
to return a promise with the resolved value assigned to key
.
Conclusion
To use async and await with Node.js AWS SDK, we can call the promise
method after we call the AWS SDK method.