Skip to content

Commit 563dbc4

Browse files
chore(docs): use top-level-await in example snippets
1 parent ad9735f commit 563dbc4

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed

README.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ const client = new Stainless({
3030
apiKey: process.env['STAINLESS_V0_API_KEY'], // This is the default and can be omitted
3131
});
3232

33-
async function main() {
34-
const buildObject = await client.builds.create({ revision: 'string' });
33+
const buildObject = await client.builds.create({ revision: 'string' });
3534

36-
console.log(buildObject.id);
37-
}
38-
39-
main();
35+
console.log(buildObject.id);
4036
```
4137

4238
### Request & Response types
@@ -52,12 +48,8 @@ const client = new Stainless({
5248
apiKey: process.env['STAINLESS_V0_API_KEY'], // This is the default and can be omitted
5349
});
5450

55-
async function main() {
56-
const params: Stainless.BuildCreateParams = { revision: 'string' };
57-
const buildObject: Stainless.BuildObject = await client.builds.create(params);
58-
}
59-
60-
main();
51+
const params: Stainless.BuildCreateParams = { revision: 'string' };
52+
const buildObject: Stainless.BuildObject = await client.builds.create(params);
6153
```
6254

6355
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -70,19 +62,15 @@ a subclass of `APIError` will be thrown:
7062

7163
<!-- prettier-ignore -->
7264
```ts
73-
async function main() {
74-
const buildObject = await client.builds.create({ revision: 'string' }).catch(async (err) => {
75-
if (err instanceof Stainless.APIError) {
76-
console.log(err.status); // 400
77-
console.log(err.name); // BadRequestError
78-
console.log(err.headers); // {server: 'nginx', ...}
79-
} else {
80-
throw err;
81-
}
82-
});
83-
}
84-
85-
main();
65+
const buildObject = await client.builds.create({ revision: 'string' }).catch(async (err) => {
66+
if (err instanceof Stainless.APIError) {
67+
console.log(err.status); // 400
68+
console.log(err.name); // BadRequestError
69+
console.log(err.headers); // {server: 'nginx', ...}
70+
} else {
71+
throw err;
72+
}
73+
});
8674
```
8775

8876
Error codes are as follows:

0 commit comments

Comments
 (0)