I am working in Angular 5 to integrate flatbuffers response with my API call. I am trying to load binary file using HttpClient in Angular 5.
I have tried below code to get byte data in Uint8Array. Also tried with Blob but its not working.
let apiUrl = "./assets/test.bin";
const headers = {
headers: new HttpHeaders({responseType: "application/octet-stream"})
};
let data : Observable<Uint8Array> = this.http.get<Uint8Array>(apiUrl, headers);
data.subscribe( (response: Uint8Array) => {
const data = response;
// console.log(data);
console.log("successful");
return data;
}, (error : HttpErrorResponse)=> {
console.log(error.error.text);
});