How do I handle server being down/unreachable when using router.visit? I tried onError and try catch but those didn't help. Maybe there's a way to get into that axios promise? 🤔
const submit = () => {
console.log("Submitting attempt...")
try {
router.post(
props.submit_route,
{
answers: answers.value,
time_taken: timeTaken.value,
},
{
onError: (error) => {
console.log("onError", error)
},
onSuccess: () => {
console.log("onSuccess")
},
onFinish: () => {
console.log("onFinish")
},
},
)
console.log("Sent post.")
} catch (error) {
console.log("try catch", error)
}
}
Submitting attempt...
Sent post.
onFinish
POST http://localhost:8000/01972048-29ab-73b3-a09e-2d680cfac87c net::ERR_CONNECTION_REFUSED
Uncaught (in promise) > AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …}