Streaming Json response with IAsyncEnumerable in .net 6.0 and example fetch in javascript

Hi, We will get the data as stream using IAsyncEnumerable and example with javascript fetch.

Let’s create project as .net 6.0 or higher because there is no support for stream data in versions below .net 6.0.

A example endpoint:

Minimal api:

How to fetch data as stream in javascript?

We will do using ReadableStream.getReader(). source

Page:

You may also like...

3 Responses

  1. Dmitry says:

    Method GetValues() has return type “IAsyncEnumerable”, so it should return items of type “string”, but it returns items of type UserModel. Does UserModel have “implicit operator string”?

Leave a Reply

Your email address will not be published.

English