Fetch with stream support.
Use cases: AI chat completion, SSE, and other uses that require streaming response and CORS.
-
Support Capacitor v7.
-
Only support android.
-
Written in kotlin, so you need to configure kotlin for your project before using it.
npm install capacitor-stream-fetch
npx cap sync
import { fetch } from 'capacitor-stream-fetch'
// Use it like native fetch
streamFetch(options: { url: string; method: string; headers: Record<string, string>; body?: string; }) => any
Execute a HTTP request with streaming response
Param | Type | Description |
---|---|---|
options |
{ url: string; method: string; headers: any; body?: string; } |
The request options |
Returns: any
addListener(eventName: string, listenerFunc: (event: any) => void) => any
Add a listener for a specific event
Param | Type | Description |
---|---|---|
eventName |
string |
Name of the event to listen for |
listenerFunc |
(event: any) => void |
Callback function to be called when the event fires |
Returns: any
removeAllListeners() => any
Remove all listeners for this plugin
Returns: any
Prop | Type |
---|---|
requestId |
number |
status |
number |
statusText |
string |
headers |
Record<string, string> |
Prop | Type |
---|---|
remove |
() => any |