i18next-http-backend icon indicating copy to clipboard operation
i18next-http-backend copied to clipboard

Possibility to add timeout to the setup

Open simonbergstrom opened this issue 1 year ago • 2 comments

🚀 Feature Proposal

Add the possibility to add timeout for fetching i18n resource like the axios config timeout. (See example here for timeout: https://axios-http.com/docs/req_config and search for timeout)

Motivation

When fetching i18n resource it would be really good to specify for how long a request is acceptable to wait for before fallbacking to fetching i18n resources from somewhere else.

Example

https://axios-http.com/docs/req_config and search for timeout

...i18n config
 backend: {
          backends: [HttpBackend, resourcesToBackend(config.resources)],
          backendOptions: [
            {
              loadPath: <URL_TO_FETCH>,
              crossDomain: true,
              timeout: 2000, // Will fallback to fetch i18n resources from file if request take more than 2 sec
            },
          ],
        },

simonbergstrom avatar Sep 25 '23 09:09 simonbergstrom

You can already do so by specifying your own fetch/request function: https://github.com/i18next/i18next-http-backend#backend-options

adrai avatar Sep 25 '23 09:09 adrai

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 15 '23 13:10 stale[bot]