Is it possible to send streaming data from WEB API to Angular ?like in open AI there is option to show data as stream it will give data in bit by bit this we can able to do in console application but can't able to do using WEB API and Angular. Here my requirement is to send Open AI Streaming response to Angular.
Loading
Praveen MishraPosted Jul 13, 2023, 7:42 AM
Here is the code to send OpenAI Streaming data from a web API to an Angular application:
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-your-component',
templateUrl: './your-component.component.html',
styleUrls: ['./your-component.component.css']
})
export class YourComponent {
constructor(private http: HttpClient) {}
fetchData() {
this.http.get('your-api-endpoint-url').subscribe(
(response) => {
// Handle the response data
console.log(response);
},
(error) => {
// Handle any errors
console.error(error);
}
);
}
}