inertia
inertia copied to clipboard
Replace Axios with native XMLHttpRequest
This PR serves as a basis / starting point for eventually migrating away from Axios. The basic functionality presented works, but file uploads have not been tested.
This PR will remain a WIP as to not accidentally get pulled in to core.
I think removing the dependency on axios is a good move. However why not use fetch instead of XMLHttpRequest?
If browser compatibility is the issue, then you can't use URLSearchParams either.
Would there still be some sort of API available to mimic axios interceptor behavior after this change?
For example, could this still be accomplished without any odd hacks:
axios.interceptors.response.use(response => response, async err => {
const status = get(err, 'response.status')
if (status === 419) {
// Refresh our session token
await axios.get('/csrf-token')
// Return a new request using the original request's configuration
return axios(err.response.config)
}
return Promise.reject(err)
})
https://dev.to/grantholle/better-csrf-refreshing-in-laravel-and-axios-177c
Hey! Thanks so much for your interest in Inertia.js and for submitting this contribution.
In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.
Of course there's a chance that this PR is still relevant, and if that's the case feel free to re-submit it. If it's a new feature and not a bug fix maybe respond here first to make sure that it's something we want to include in the library.
Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️