-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Cannot read property 'status' of undefined #127
Comments
Perhaps an API to catch errors would be a great addition. With an interception API you would be able to catch no network errors etc. 🙂 let api = Inertia.init(...);
api.interceptors.response.use((response) => response, (error) => {
// whatever you want to do with the error
}); It might even solve the highly requested feature: custom progress bar?
|
+1 Same here |
Thanks for reporting this. I agree, we need a better solution here. I plan to get back into some serious Inertia development in June, and I'll try and tackle this at that time. 👍 |
So I believe this has been corrected now. In the event that there is no response, the promise will simply fail, without causing another error. Plus, you can now catch these errors using the new event system: import { Inertia } from '@inertiajs/inertia'
Inertia.on('error', event => {
console.log(`An unexpected error occurred during an Inertia visit.`)
console.log(event.detail.error)
// Prevent the error from being thrown
event.preventDefault()
}) |
Inertia doesn't handle cases when a request fails without a response (e.g. no network).
In that case the
error.response
is null.inertia/src/inertia.js
Line 83 in 70b6bda
Suggestion before line 83:
The text was updated successfully, but these errors were encountered: