ASI Solutions, Data Team Leader, Hein Taljaard share his insights on how to unleash the full potential of your data with Azure OpenAI. Let’s start talking to our data and give your organisation the competitive edge for success in 2024 and beyond! 

When we talk about a “minimal API with React,” we are typically discussing the development of a lightweight backend API designed to provide data to a React frontend. The primary objective is to maintain simplicity within the API, concentrating on delivering only the fundamental functionality necessary for the frontend application.

This functionality might include features such as:

GetStream API with React

By using GetStream React, developers can leverage pre-built components and utilities specifically designed for integrating GetStream’s functionality seamlessly into React-based applications. These components often include features such as activity feeds, notifications, user profiles, and social engagement functionalities.
In our getStream function, we’ll incorporate the HTTP response object and name it response. Our initial step involves setting up the content header for text event streaming, by adding response.headers.add(‘Content-Type’, ‘text/event-stream’).

The additions we’re making are quite minimal from an API standpoint. When working with normal OpenAI, we’re only sending text back to the client.

In some cases, there might be a need for code markup. Therefore, it is important to ensure a proper handling of this on your client, especially as we begin integrating our own data. This is particularly important when it comes to taking incoming text and rendering it directly onto a div or any other element.


await foreach API with React

To use the await foreach pattern with an API call in a React application, you typically fetch data asynchronously and then iterate over the results using await foreach to handle the data as it arrives.

After successfully executing the getStream function, we will proceed to command await foreach function, essentially instructing to go and fetch the stream, checking if the content is not null and updated, and sending the signal that “alright, if the content is not null, then we can carry on.”

Followed by a code  — if (chatUpdate.content is not null) This code checks if chatUpdate.content is not null. If it’s not null, it proceeds to execute response.bodyWriter.WriteAsync() note that we must encode the content update to send it as a byte array.

However, it’s important to note that every time you intend for the client to receive what you’re sending, you must flush the body writer. This can be achieved by calling response.bodyWriter.FlushAsync().


By using the above functionality, you can implement real-time streaming of information with minimal API in your React application, enabling interactive and engaging user experiences.