Skip to content

Commit 6a5e99d

Browse files
chore(docs): use top-level-await in example snippets
1 parent f2a13cf commit 6a5e99d

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

README.md

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@ const client = new Arcade({
2626
apiKey: process.env['ARCADE_API_KEY'], // This is the default and can be omitted
2727
});
2828

29-
async function main() {
30-
const executeToolResponse = await client.tools.execute({
31-
tool_name: 'Google.ListEmails',
32-
input: { n_emails: 10 },
33-
user_id: '[email protected]',
34-
});
35-
36-
console.log(executeToolResponse.id);
37-
}
29+
const executeToolResponse = await client.tools.execute({
30+
tool_name: 'Google.ListEmails',
31+
input: { n_emails: 10 },
32+
user_id: '[email protected]',
33+
});
3834

39-
main();
35+
console.log(executeToolResponse.id);
4036
```
4137

4238
### Request & Response types
@@ -51,14 +47,10 @@ const client = new Arcade({
5147
apiKey: process.env['ARCADE_API_KEY'], // This is the default and can be omitted
5248
});
5349

54-
async function main() {
55-
const params: Arcade.Chat.CompletionCreateParams = {
56-
messages: [{ role: 'user', content: 'Hello, how can I use Arcade?' }],
57-
};
58-
const chatResponse: Arcade.ChatResponse = await client.chat.completions.create(params);
59-
}
60-
61-
main();
50+
const params: Arcade.Chat.CompletionCreateParams = {
51+
messages: [{ role: 'user', content: 'Hello, how can I use Arcade?' }],
52+
};
53+
const chatResponse: Arcade.ChatResponse = await client.chat.completions.create(params);
6254
```
6355

6456
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -71,21 +63,17 @@ a subclass of `APIError` will be thrown:
7163

7264
<!-- prettier-ignore -->
7365
```ts
74-
async function main() {
75-
const chatResponse = await client.chat.completions
76-
.create({ messages: [{ role: 'user', content: 'Hello, how can I use Arcade?' }] })
77-
.catch(async (err) => {
78-
if (err instanceof Arcade.APIError) {
79-
console.log(err.status); // 400
80-
console.log(err.name); // BadRequestError
81-
console.log(err.headers); // {server: 'nginx', ...}
82-
} else {
83-
throw err;
84-
}
85-
});
86-
}
87-
88-
main();
66+
const chatResponse = await client.chat.completions
67+
.create({ messages: [{ role: 'user', content: 'Hello, how can I use Arcade?' }] })
68+
.catch(async (err) => {
69+
if (err instanceof Arcade.APIError) {
70+
console.log(err.status); // 400
71+
console.log(err.name); // BadRequestError
72+
console.log(err.headers); // {server: 'nginx', ...}
73+
} else {
74+
throw err;
75+
}
76+
});
8977
```
9078

9179
Error codes are as follows:

0 commit comments

Comments
 (0)