[Code Demo] Using Response Stream from Fetch API | JSer - Front-End Interview questions

preview_player
Показать описание

Fetch API Response Stream gives us the possibility to handle response in a progressive way rather than waiting for the whole data to arrive. Pretty powerful if the server logic is heavy, or the response is purely too much a burden.

more resources on MDN:

Hi I'm a JavaScript engineer who is not good at algorithms,
and currently practicing leetCode & BFE.dev. If you are interested, maybe we can learn together.
Рекомендации по теме
Комментарии
Автор

Thanks, this helps. But when stream is too long, got cut into pieces, how to solve it? like "[receive] happ", "[receive] y, year!"

jenniechen
Автор

So for this to work, the server has to serve data chunk by chunk, am I correct?
If I serve a video without dividing it into pieces, then when I fetch the video, I still have to wait for the whole video to be downloaded, am I correct?

greyekuo
Автор

Hi, is it just me or does this not work as expected anymore? In both my application the linked sandbox, the text is output all at once.

vaughngx
Автор

Thank you, currently we are using streamingAPI to serve big csv files where users can download it.. is there any other advantages or usecases of streamingAPI where i can use it ?

hackwithharsha