Home  >  Q&A  >  body text

Unable to catch network error when sending request using Inertia + Vue

I am unable to catch network errors when sending this.$inertia.patch request. I'm shutting down the backend server to simulate a lost connection. The console displays: Uncaught (in Promise) Error: Network Error.

I've tried Inertia's onError, tried adding .catch after the request and a separate try...catch and using Vue 2

errorCaptured: function(err) {
   console.log('Caught error', err.message)
},

I can provide more details if needed.

So basically trying to catch net::ERR_CONNECTION_REFUSED

Edit: I started using onFinish along with onSuccess and onStart, but ended up using axios

P粉222320176P粉222320176205 days ago379

reply all(1)I'll reply

  • P粉935883292

    P粉9358832922024-03-28 09:42:14

    Use onStart with onSuccess and onFinish:

    • If a network error occurs, onFinish will fire and onSuccess.
    • If a server error occurs, onError will be triggered with onFinish

    reply
    0
  • Cancelreply