Тёмный

Using fetch with server-sent events 

Covalence
Подписаться 8 тыс.
Просмотров 8 тыс.
50% 1

In this video, we'll use Microsoft's fetch-event-source package to use fetch to listen for our own server-sent events generated by our very own Node.js Express server. Using fetch allows us to add a payload to our request, use HTTP methods like POST, PUT, and DELETE, and include headers for authentication and authorization purposes. This is super useful for things ranging from displaying real-time data that changes frequently (think stock ticker) all the way to streaming those ChatGPT responses :)
GitHub Repo: github.com/cov...
Express Template with Browserify: github.com/cov...
Don't forget to like this video and subscribe to our channel - we're publishing more videos and walkthroughs every week. Comment below and let us know what you'd like to see next!
Join the Covalence community: covalence.io
Shop Covalence merch: covalence.merc...

Опубликовано:

 

29 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 12   
@miazam123
@miazam123 Год назад
Your video solved my issue. The connection was getting closed shortly after subscribing for events as I was not using X-Accel-Buffering header. Thanks!
@bhimeshk4866
@bhimeshk4866 6 месяцев назад
I'm so thankful for making this video, it's really helpful. I'm facing with a challenge after initial response, event source is getting closed. Hope I will hear back from you!!
@anhtuantran4423
@anhtuantran4423 7 месяцев назад
thanks! that helped a lot! is there a way to keep fetching and streaming data when switching tabs? openWhenHidden: true keeps the connection alive but when streaming data it pauses when switching tabs or minimize the browser. can i keep streaming even when the browser is minimized or the tab is switched?
@covalence-io
@covalence-io 7 месяцев назад
This may be a memory/processing limitation implemented by the browser. Have you looked into whether this is the case in every browser? Regardless, it may be a solution you have to handle by immediately grabbing the data you've missed once the session becomes active again.
@GuilhermeXavier883
@GuilhermeXavier883 5 месяцев назад
thank you my friend, you help a lot here
@daringcalf
@daringcalf Год назад
fetchEventSource starting 12:27
@RubiBox369
@RubiBox369 5 месяцев назад
Intro look like ww3
@pavithramkumar6276
@pavithramkumar6276 Год назад
Hello, I watched this video and its amazing. I am stuck with a problem however, i am using this in a react application to get status updates from the server to the frontend. i am getting the status updates properly. however, the very first message i receive cannot be updated using setstateVariable(var) [ .... this is an example of useState() variable i have used in the functinal component]. But I can update the next following messages. Idont understand why that is so. if you have ever experienced this weird issue and know the solution it would be of great help. thank you
@covalence-io
@covalence-io Год назад
Hmm seems like a problem that's pretty specific to how you have your code in particular. I'd recommend logging everywhere you're setting that variable and making sure the values are what you expect them to be and also make sure there's no race conditions where something else is setting the value after your first message is received
@julesbloux4279
@julesbloux4279 3 месяца назад
in french we say "tu me régales"
@mastertheblaster9997
@mastertheblaster9997 Год назад
How to terminate the connection
@covalence-io
@covalence-io Год назад
You can use AbortController from the frontend which I talk about briefly at 14:14 or you can close the connection from the backend
Далее
Getting Started with Redis for Free!
23:15
Просмотров 924
Using EventSource with SSE
27:52
Просмотров 8 тыс.
Server-Sent Events Crash Course
29:48
Просмотров 95 тыс.
React Server Components: A Comprehensive Breakdown
52:42
Next.js with a separate server - good idea?
22:53
Просмотров 66 тыс.
Server-Sent Events with NestJS
9:54
Просмотров 32 тыс.