Next.js Discord

Discord Forum

Help needed in SSR using a streaming http request for data

Unanswered
Savannah posted this in #help-forum
Open in Discord
SavannahOP
Hey all,
I have a server component which fetches data from my other service which returns the data as an HTTP stream.
What I want to achieve is that with each chunk received from the request, to re-render some parts of the page.
I tried using a fetch request with body.getReader() and then await each chunk and update the data object which is being rendered.
That did not work, so I tried using axios and with stream.on() I was updating the object.
Both didn't work, and I was only able to render the page correctly awaiting all chunks to arrive, and the using the return statement, which resulted in long waiting time.
How would I start a fetch request, and with each chunk update the rendered component?

0 Replies