Reputation: 11202
I have a REST API that returns either:
The first scenario works with responseType: 'blob'
and the second works with responseType: 'json'
.
Can I somehow set the responseType
after getting the response (i.e. depends on HTTP status code, etc.).
Upvotes: 3
Views: 1294
Reputation: 2078
You can not.
P.S. Same REST API method returns blob either json? really? Probably you can distinguish at frontend somehow, by some argument value or so and set 'responseType' accordingly.
Or always expect blob then try to parse it with filereader and check if there is JSON inside.
Or implement interceptor. You can adjust response headers and content then.
Upvotes: 1