Display general error message from server
How can we show a general (not linked to a specific field) error message from an API?
We have a login api that throws an error but not on a specific field because we don't want the user to know which field is wrong (obviously).
This now shows the error on the password field, But i rather dont want to do that and set it on 'server' for example and show that message.
I have found that other people handle this state outside of the form with just a simple
const [error, setError] = useState()
and set that error but what do i return in the catch? because i need to return some error in the onSubmitAsync to actually stop the from from handling onSubmit
2 Replies
other-emeraldOP•2mo ago
I already find it really weird that we basically forcing the mutation already in the validators (yes it handles validation as well).
It would be imo way more intuitive if we could set errors outside of validators as well so we could do
rival-black•2mo ago
From the Form Validation Docs:
as for setting errors in
onSubmit
, it's currently being discussed. One issue it has is that (as you see it too), making it intuitive is hard, but it would be nice to return it somehow.