INTEGRITY Cloudflare Docs

EventSource

Background

The EventSource interface is a server-sent event API that allows a server to push events to a client. The EventSource object is used to receive server-sent events. It connects to a server over HTTP and receives events in a text-based format.

Constructor

let eventSource = new EventSource(url, options);

By default, the EventSource will use the global fetch() function under the covers to make requests. If you need to use a different fetch implementation as provided by a Cloudflare Workers binding, you can pass the fetcher option:

export default {
  async fetch(req, env) {
    let eventSource = new EventSource(url, { fetcher: env.MYFETCHER });
    // ...
  }
};

Note that the fetcher option is a Cloudflare Workers specific extension.

Properties

Methods

Events

Class Methods