@@ -26,13 +26,9 @@ const client = new Browserbase({
2626 apiKey: process .env [' BROWSERBASE_API_KEY' ], // This is the default and can be omitted
2727});
2828
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' });
3130
32- console .log (session .id );
33- }
34-
35- main ();
31+ console .log (session .id );
3632```
3733
3834### Request & Response types
@@ -47,12 +43,8 @@ const client = new Browserbase({
4743 apiKey: process .env [' BROWSERBASE_API_KEY' ], // This is the default and can be omitted
4844});
4945
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 );
5648```
5749
5850Documentation 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:
9587
9688<!-- prettier-ignore -->
9789``` 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+ });
11199```
112100
113101Error codes are as follows:
0 commit comments