'Unable to catch Network Error when sending request using Inertia + Vue
While sending a this.$inertia.patch request I'm unable to catch a Network Error. I'm turning off the backend server to emulate a lost connection. The console shows: Uncaught (in promise) Error: Network Error.
I've tried Inertia's onError, tried adding a .catch after the request as well as a separate try...catch and used the Vue 2's
errorCaptured: function(err) {
console.log('Caught error', err.message)
},
I can give more details if needed.
So basically trying to catch net::ERR_CONNECTION_REFUSED
Edit: I moved to using onFinish along with onSuccess and onStart, but finally used axios
Solution 1:[1]
Use onStart along with onSuccess and onFinish:
- In the case of a network error,
onFinishwill trigger withoutonSuccess. - In the case of a server error
onErrorwill trigger withonFinish
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gX. |
