capacitor-stream-fetch
v0.0.6
Published
A capacitor plugin provides `fetch` with stream support
Readme
capacitor-stream-fetch
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.
Install
npm install capacitor-stream-fetch
npx cap syncUsage
import { fetch } from 'capacitor-stream-fetch'
// Use it like native fetchAPI
streamFetch(...)
streamFetch(options: { url: string; method: string; headers: Record<string, string>; body?: string; }) => anyExecute a HTTP request with streaming response
| Param | Type | Description |
| ------------- | -------------------------------------------------------------------------- | ------------------- |
| options | { url: string; method: string; headers: any; body?: string; } | The request options |
Returns: any
addListener(string, ...)
addListener(eventName: string, listenerFunc: (event: any) => void) => anyAdd 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()
removeAllListeners() => anyRemove all listeners for this plugin
Returns: any
Interfaces
StreamResponse
| Prop | Type |
| ---------------- | ----------------------------------------- |
| requestId | number |
| status | number |
| statusText | string |
| headers | Record<string, string> |
PluginListenerHandle
| Prop | Type |
| ------------ | ------------------------- |
| remove | () => any |
