🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More
Socket
Book a DemoInstallSign in
Socket

sse-fetch

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sse-fetch

use fetch

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

fetch-event-source

使用 fetch 实现 EventSource, 支持 fetch 的所有功能

install

$ npm install sse-fetch

usage

import EventSource from 'sse-fetch';
const eventSource = new EventSource('http://localhost:3000/sse', {
  method: 'POST',
});

eventSource.addEventListener('message', (event) => {
  console.log(event.data);
});

API

除了支持 EventSource 的及 fetch 的所有配置,还支持以下配置:

属性名类型默认值描述
jsonbooleanfalse如果 data 为 json 是否自动解析返回的 json
serverEndbooleanfalse如果服务端主动关闭连接,客户端不再尝试重连

Keywords

fetch

FAQs

Package last updated on 08 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts