Method
page.request()
Performs an HTTP request through the device’s network connection.
url: URL to make the request tooptions(optional): Request options
Result object with:
value(options?): Promise that resolves to response datastream: Internal stream objectreadable:ReadableStream<Uint8Array>for streaming response bodybytes(): Promise that consumes stream and returnsUint8Arrayjson(): Promise that consumes stream and returns parsed JSONclose(): Close the stream
Complete examples
API calls with mobile headers
POST data to API
Authenticated API requests
Download file
Streaming response
Get response as bytes
Get response as JSON
Upload file
GraphQL query
Retry failed requests
Paginated API requests
Check API availability
Best practices
Set appropriate timeouts
Set appropriate timeouts
Always set timeouts for requests to avoid hanging:
Close responses
Close responses
Call
value({ close: true }) to properly close the response:Handle errors
Handle errors
Wrap requests in try-catch blocks:
Use mobile-specific headers
Use mobile-specific headers
Include appropriate headers for mobile API endpoints: