Use async/await - AWS SDK for JavaScript

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).

Use 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:

  • Install the AWS SDK for JavaScript DynamoDB client by entering npm install @aws-sdk/client-dynamodb in the command line of your project.

  • Ensure you have configured your AWS credentials correctly. For more information, see Set credentials.

import { DynamoDBClient, ListTablesCommand } from "@aws-sdk/client-dynamodb"; (async function () { const dbClient = new DynamoDBClient({ region: "us-west-2" }); const command = new 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.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy