@@ -26,13 +26,9 @@ const client = new Browserbase({
26
26
apiKey: process .env [' BROWSERBASE_API_KEY' ], // This is the default and can be omitted
27
27
});
28
28
29
- async function main () {
30
- const session = await client .sessions .create ({ projectId: ' your_project_id' });
29
+ const session = await client .sessions .create ({ projectId: ' your_project_id' });
31
30
32
- console .log (session .id );
33
- }
34
-
35
- main ();
31
+ console .log (session .id );
36
32
```
37
33
38
34
### Request & Response types
@@ -47,12 +43,8 @@ const client = new Browserbase({
47
43
apiKey: process .env [' BROWSERBASE_API_KEY' ], // This is the default and can be omitted
48
44
});
49
45
50
- async function main() {
51
- const params: Browserbase .SessionCreateParams = { projectId: ' your_project_id' };
52
- const session: Browserbase .SessionCreateResponse = await client .sessions .create (params );
53
- }
54
-
55
- main ();
46
+ const params: Browserbase .SessionCreateParams = { projectId: ' your_project_id' };
47
+ const session: Browserbase .SessionCreateResponse = await client .sessions .create (params );
56
48
```
57
49
58
50
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -95,19 +87,15 @@ a subclass of `APIError` will be thrown:
95
87
96
88
<!-- prettier-ignore -->
97
89
``` ts
98
- async function main() {
99
- const session = await client .sessions .create ({ projectId: ' your_project_id' }).catch (async (err ) => {
100
- if (err instanceof Browserbase .APIError ) {
101
- console .log (err .status ); // 400
102
- console .log (err .name ); // BadRequestError
103
- console .log (err .headers ); // {server: 'nginx', ...}
104
- } else {
105
- throw err ;
106
- }
107
- });
108
- }
109
-
110
- main ();
90
+ const session = await client .sessions .create ({ projectId: ' your_project_id' }).catch (async (err ) => {
91
+ if (err instanceof Browserbase .APIError ) {
92
+ console .log (err .status ); // 400
93
+ console .log (err .name ); // BadRequestError
94
+ console .log (err .headers ); // {server: 'nginx', ...}
95
+ } else {
96
+ throw err ;
97
+ }
98
+ });
111
99
```
112
100
113
101
Error codes are as follows:
0 commit comments