You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that message attribute could also be a part of fail just as it is with error.
As you describe it, FAIL is:
There was a problem with the data submitted, or some pre-condition of the API call wasn't satisfied
So in case of the former, the "problem with the data submitted" current structure makes perfect sense.
However for "some pre-condition of the API call wasn't satisfied" it does not quite work, and a "message" describing the problem seems to be much more logical. Because this pre-condition may not depend on what data user submitted, but on other conditions outside of it. For example maybe this request only works on certain days of the week?
It also allows to handle both fail and error responses in the same way, by showing an error or warning and message response from the server.
The text was updated successfully, but these errors were encountered:
What I usually do is adds a friendly message in the errors array. I always send errors as an array of objects in data, which has a message attribute. So the front-end engineers know the cause of failure.
{
"status": "fail",
"data": {
"errors": [
{
"message": "Request body should be json"
}
]
}
}
I think that
message
attribute could also be a part offail
just as it is witherror
.As you describe it, FAIL is:
So in case of the former, the "problem with the data submitted" current structure makes perfect sense.
However for "some pre-condition of the API call wasn't satisfied" it does not quite work, and a "message" describing the problem seems to be much more logical. Because this pre-condition may not depend on what data user submitted, but on other conditions outside of it. For example maybe this request only works on certain days of the week?
It also allows to handle both
fail
anderror
responses in the same way, by showing an error or warning andmessage
response from the server.The text was updated successfully, but these errors were encountered: