Skip to content
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

It's not possible to override Axios network adapter #7

Open
tomaszmadeyski opened this issue Jul 22, 2022 · 0 comments
Open

It's not possible to override Axios network adapter #7

tomaszmadeyski opened this issue Jul 22, 2022 · 0 comments

Comments

@tomaszmadeyski
Copy link

In Config.ts you expose configuration value:

 /**
   * Override the standard adapter used by Axios to connect to the ContentDelivery API.
   */
  networkAdapter ?: AxiosAdapter

Which is then checked in RepositoryModule :

const newApiClassicConfig : Partial<IContentDeliveryConfig> = {

            Adapter: config.networkAdapter || isFetchApiAvailable() ? FetchAdapter : undefined,
            BaseURL: config.epiBaseUrl,
            AutoExpandAll: config.autoExpandRequests,
            Debug: config.enableDebug,
            EnableExtensions: true,
            Language: config.defaultLanguage
        };

however, there's a bug here

Adapter: config.networkAdapter || isFetchApiAvailable() ? FetchAdapter : undefined,

as it works as parenthesis were like this:

Adapter: (config.networkAdapter || isFetchApiAvailable()) ? FetchAdapter : undefined

Due to the fact that isFetchApiAvailable() is (almost) always true, then FetchAdapter is used, despite the fact that config.networkAdapter is passed in the configuration

This makes it impossible to change network adapter to custom value as FetchAdapter is always used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant