Closed MagicalTux closed 4 years ago
Not 100% what the benefit of adding this is? Could you explain? Without further explanation, it looks like adding code to use a newer feature for the sake of using a newer API...or is there a benefit I miss?
Most people doing SSR (like we are doing) do not have XMLHttpRequest. There are polyfills existing (see https://www.npmjs.com/package/xmlhttprequest for example) however most browsers (except IE11) also support the newer fetch() API, which has a cleaner API in general in order to define passing credentials/cors/etc.
Ideally the whole thing should be rewritten to use fetch() syntax and fallback to XMLHttpRequest in rare cases when fetch() is unavailable (or use a polyfill for fetch()), however I wanted to keep changes localized and with a minimal impact.
there is already an alternative: https://github.com/perrin4869/i18next-fetch-backend
or is there a benefit I miss?
For a PWA with offline-first approach all offline-capable resources need to be loaded with fetch, XHR is not compatible.
Right now my app is using i18next-xhr-backend
and this breaks the offline capability of the rest of the app when the device has no service.
@julianwachholz still there is: https://github.com/perrin4869/i18next-fetch-backend for that case
Adding support for modern fetch() api through the existing ajax() method and keeping compatibility as much as possible.