I have an API which responds an object like this:
{
"statusCode": 200,
"errors": [],
"data": []
}
Sometimes it responds with data and sometimes responds with an array of errors.
but the status code in headers always is 200 (OK).
so the subscriber always gets next notification in observable stream even if the respond has some errors.
the question is how can I transform the next notification to error notification in observable stream so the subscriber get error notification like when the request is not (OK).
I can't use throw new Error() because it only can accept string while I want to give subscriber response object.