In this example, inside form submit handler, apollo request wrapped in try/catch block:
async function handleSubmit(event) {
event.preventDefault()
const emailElement = event.currentTarget.elements.email
const passwordElement = event.currentTarget.elements.password
try {
await client.resetStore()
const { data } = await signIn({
variables: {
email: emailElement.value,
password: passwordElement.value,
},
})
if (data.signIn.user) {
await router.push('/')
}
} catch (error) {
setErrorMsg(getErrorMessage(error))
}
}
Is there more elegant way to catch network errors, not using try/catch?
Or i should just ignore console error:
Uncaught (in promise) Error: Network error: Response not successful: Received status code 400
And use error prop?
const [login, { error }] = useMutation(LoginMutation)