Streaming
Types of streaming
Server-sent events (SSE) JSON streaming
Server-sent events (SSE aka Event Stream)
" id" : The event ID "event": The event type "data": The event data "retry": The time in milliseconds before the client should try to reconnect
When toddle receives an entire event, it will emit an "On message"-event with the event data. This is a "
You can read more about the specs of SSE
JSON streaming
On Message Event
Change the response behavior
If the header is set to "text/event-stream," toddle will parse it as a stream of server-side events.
Likewise, if the header is set to "application/stream+json" or "application/x-ndjson" toddle will parse it as a stream of JSON objects.
You might run into a case where the server is not setting the Content-Type header correctly. In these cases, you can override the default parsing behavior to match your expectations. This is done by setting the "Response Parsing" configuration in the advanced tab of the API to "Event Stream" or "JSON stream." This will cause toddle to ignore the Content-Type header and parse the response as a stream of server-side events or JSON objects, respectively.