As the title says, I'm wondering if there is a way to use an EventSource instance (EventSource - Web APIs | MDN) in Retool's Javascript resource.
I saw in an old post from 2020 a user was citing code that uses EventSource directly in retool (Process Incoming Webhooks for Retool). However, when I tried to use it myself in the JS resource it tells me that " 'EventSource' is not defined".
Hey @Abderrahman_Sobh! Doing some testing it looks as though Retool does support the EventSource API, would you mind sending over a screenshot of the code you're trying to call it in for context?
I'm seeing the same thing though it looks like it may only be a linting error, the following is from a test app that listens to events from a localhost server and seems to work fine:
Based on the EventSource docs though it looks like the API might not support passing Authorization headers. I'm not very familiar with it and could easily be wrong, but do wonder if that might be causing issues here. server_sent_events.json
Can you share more about your use case? Are you also looking to pass in auth headers? As far as I can tell, adding headers isn't supported, but I'm curious if you have this implemented somewhere outside of Retool
Got it! I haven't tested EventSource in a custom component, but in general, for realtime uses cases, I recommend trying a custom React component (see similar suggestion here).