Using async/await - AWS SDK for JavaScript

Help us improve the AWS SDK for JavaScript version 3 (V3) documentation by providing feedback using the Feedback link, or create an issue or pull request on GitHub.

The AWS SDK for JavaScript V3 API Reference Guide describes in detail all the API operations for the AWS SDK for JavaScript version 3 (V3).

Using async/await

Rather than using promises, you should consider using async/await. Async functions are simpler and take less boilerplate than using promises. Await can only be used in an async function to asynchronously wait for a value.

The following example uses async/await to list all of your Amazon DynamoDB tables in us-west-2.

Note

For this example to run:

(async function () { const DDB = require("@aws-sdk/client-dynamodb"); const dbClient = new DDB.DynamoDBClient({ region: "us-west-2" }); const command = new DDB.ListTablesCommand({}); try { const results = await dbClient.send(command); console.log(results.TableNames.join('\n')); } catch (err) { console.error(err) } })();
Note

Not all browsers support async/await. See Async functions for a list of browsers with async/await support.