I am creating a project in Angular that takes data from a GET call from an API, filters out specific data from the call, and writes it to a text file. I believe I am close on filtering out the data, but I am getting the error
Type '{ line1: any; line2: any; }' is missing the following properties from type 'Blob': size, type, arrayBuffer, slice, and 2 more.
Here is the typescript code where I am getting an error
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': this.token
})
};
this.http.get(this.url, httpOptions).subscribe((response) => {
this.response = response;
let line_1_2 = {line1:this.response.line1 , line2:this.response.line2};
const blob = new Blob([line_1_2], { type: 'text/csv' });
const url= window.URL.createObjectURL(blob);
window.open(url);
});
The line I am getting an error is:
const blob = new Blob([line_1_2], { type: 'text/csv' });
What do I need to do to make my object line_1_2 recognizable as a blob to print to a text file?