I am facing an issue with calling a server that returns a csv file as text. I am using Angular's HttpClient and I need to prevent it from trying to cast the csv file to JSON. I tried setting the responseType to 'text' in the httpOptions, but it resulted in a TypeScript error that I had to ignore using @ts-ignore.
This is the code I am using:
const httpOptions = {
headers: new HttpHeaders({
Accept: "text/plain",
"Content-Type": "application/json",
}),
responseType: "text",
};
return this.httpClient.post<string>(
`/api/csv`,
{
id: "1111",
// more data
},
httpOptions
);
The error message is too long for me to pinpoint the exact issue. I found this solution on Stack Overflow, but it seems to be outdated. Unfortunately, I am unable to identify the problem here.
This is the error I am getting:
[Error message here]
Can anyone help me identify what I am missing?