This is kind of a confusing question, but hopefully someone can help.
Basically I am calling an API from a service in Angular 11 that can return one of two things.
- If the API processes the uploaded file correctly, it returns a new File to the user.
- If the API doesn't process the uploaded file correctly, it returns JSON to the user
How do I write a request that can handle either the response being a File or the response being JSON? I am having a ton of trouble with it.
Thanks in advance.
(My current request in my service)
return this._http.post(this.baseUrl, formData, {observe: 'response', responseType: 'blob'});