Handling error reposnses from server functions
Then, what we get when calling the endpoint is the response returned from the function, i.e. we get directly the result that is sent in the body of the response.
How to handle more complex scenarios, where we require access to other properties of the response? It seems that as a result we get only the return value of the function. But what if function would return different body for HTTP status code 403? How to handle that separately? As i see it right now, if we return two different bodies based on some condition, we get "union typed" result that allows us use either success response or failed response.
We could check the result and cast it to appropriate type, but that seems not ideal.
I would like to have something like below