fanout / django-eventstream

Server-Sent Events for Django
MIT License
638 stars 84 forks source link

Can't parse stream-error data into json #107

Closed simlist closed 1 year ago

simlist commented 1 year ago

When I try to parse the data from a stream-error event into json I get the following error:

Uncaught SyntaxError: Expected property name or '}' in JSON at position 1

The error is caused by the strings in the data object having single quotes.

{'condition': 'forbidden', 'text': 'Permission denied to channels: orders', 'channels': ['orders']}

If I do JSON.parse(event.data.replaceAll("'", '"')) to replace the single quotes with double quotes, then there is no error.

jkarneges commented 1 year ago

Thanks for the report! This is now fixed.

simlist commented 1 year ago

Thank you very much! Great package.