File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,8 +4,20 @@ async function main() {
44 const kernel = new Kernel ( ) ;
55
66 const browser = await kernel . browsers . create ( { } ) ;
7- const response = await kernel . browsers . fetch ( browser . session_id , 'https://example.com' , { method : 'GET' } ) ;
8- console . log ( 'status' , response . status ) ;
7+
8+ // Raw browser curl: streams the response. Use for large responses, when you want to stream,
9+ // or when you want fetch() / Response semantics.
10+ const response : Response = await kernel . browsers . fetch ( browser . session_id , 'https://example.com' , {
11+ method : 'GET' ,
12+ } ) ;
13+ console . log ( 'body' , await response . text ( ) ) ;
14+
15+ // Buffered browser curl: returns the full response in a JSON envelope. Use for small responses.
16+ const buffered = await kernel . browsers . curl ( browser . session_id , {
17+ url : 'https://example.com' ,
18+ method : 'GET' ,
19+ } ) ;
20+ console . log ( 'body' , buffered . body ) ;
921
1022 await kernel . browsers . deleteByID ( browser . session_id ) ;
1123}
You can’t perform that action at this time.
0 commit comments