Open a Server-Sent Events connection with automatic reconnection. Tracks Last-Event-ID and honours the server's retry interval. Returns an AsyncGenerator that yields SSEEvent objects.
Optional
Max reconnect attempts (default: Infinity)
for await (const event of sse('https://api.example.com/events')) { console.log(event.event, event.data);} Copy
for await (const event of sse('https://api.example.com/events')) { console.log(event.event, event.data);}
Open a Server-Sent Events connection with automatic reconnection. Tracks Last-Event-ID and honours the server's retry interval. Returns an AsyncGenerator that yields SSEEvent objects.