0.0.3 • Published 5 months ago

capacitor-stream-fetch v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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 sync

Usage

import { fetch } from 'capacitor-stream-fetch'
// Use it like native fetch

API

streamFetch(...)

streamFetch(options: { url: string; method: string; headers: Record<string, string>; body?: string; }) => any

Execute a HTTP request with streaming response

ParamTypeDescription
options{ url: string; method: string; headers: any; body?: string; }The request options

Returns: any


addListener(string, ...)

addListener(eventName: string, listenerFunc: (event: any) => void) => any

Add a listener for a specific event

ParamTypeDescription
eventNamestringName of the event to listen for
listenerFunc(event: any) => voidCallback function to be called when the event fires

Returns: any


removeAllListeners()

removeAllListeners() => any

Remove all listeners for this plugin

Returns: any


Interfaces

StreamResponse

PropType
requestIdnumber
statusnumber
statusTextstring
headersRecord<string, string>

PluginListenerHandle

PropType
remove() => any
0.0.3

5 months ago