We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi – the decode process works fine only if the server respond with just strings.
But the Server-Sent Events (SSE) standard implies a more complex response:
interface EventMessage { /** * Message payload */ data?: string; /** * Message identifier, if set, client will send `Last-Event-ID: <id>` header on reconnect */ id?: string; /** * Message type */ event?: string; /** * Update client reconnect interval (how long will client wait before trying to reconnect). */ retry?: number; /** * Message comment */ comment?: string; }
Fort that reason I suggest to add an option to let the code not just parse simple text answers but also a SSE compliant response.
Inside the decodeStreamToJson function you could parse the complex response like that:
const decoded = decoder.decode(value); const splitted = decoded .split("\n") .filter((s) => { if (s?.startsWith("data:")) return true; return false; }) .map((s) => s.replace("data: ", "")); if (splitted.length > 0 && splitted[0] !== "Stream closed") { yield splitted[0]; }
Just a suggestion. Thanks for this Hook ;)
The text was updated successfully, but these errors were encountered:
Hi @ttessarolo, thanks for the suggestion! Feel free to create a PR with this solution and I will test it out.
Sorry, something went wrong.
No branches or pull requests
Hi –
the decode process works fine only if the server respond with just strings.
But the Server-Sent Events (SSE) standard implies a more complex response:
Fort that reason I suggest to add an option to let the code not just parse simple text answers but also a SSE compliant response.
Inside the decodeStreamToJson function you could parse the complex response like that:
Just a suggestion. Thanks for this Hook ;)
The text was updated successfully, but these errors were encountered: