Is EventSource available in Retool's "Run JS Code" Resource?

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".

Is there any way I can add/enable EventSource?

Thanks

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?

1 Like

Sure, I'm just trying to instantiate a new object and it says that EventSource is undefined. Here is a screenshot:

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