-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Is your feature related to a problem?
Some endpoints (e.g. fund) return texts on success and objects on erros.
It is not easy to parse an error if we expect the response to be a text.
In JS after a fetch, when we do
const realRez = await fetchRez.text()
we get a string no matter if we really got a string or an object from the endpoint, and after that we can't do any more
const realRez = await fetchRez.json()
.
An option is to use a try{}catch(){}
, but putting in a try{}catch(){}
to try convert that string into an object to see if we got an error is not an elegant sollution, and it takes a lot more code to verify if the const realRez = await fetchRez.text()
is not actually an error object.
Checking for content-type is also an option, but it will be just so much easier typescitpt-wize to always get an object.
Describe the feature you'd like
For the API users, it will be a lot easier to always return an object in the API calls.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status