Skip to content

Conversation

@kingcean
Copy link

@kingcean kingcean commented Jan 4, 2026

Description:

Extends fromFetch function to enable Server-Sent Events.

import { fromFetch } from 'rxjs/fetch';

// URL_WITH_STREAM_MODE = "…";
// REQUEST_BODY = {…};

const data$ = fromFetch(URL_WITH_STREAM_MODE, {
  selector: 'sse'
  method: "POST",
  body: JSON.stringify(REQUEST_BODY),
  mode: "cors",
  credentials: "include",
  headers: {
    "Content-Type": "application/json",
    "Accept": "text/event-stream, application/json"
  },
});

data$.subscribe({
  next: result => console.log(result),
  complete: () => console.log('done')
});

Related issue:

Discussion #7584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant