Skip to content

FEA Support Axios 'fetch' adapter in order to support more serverless platforms #740

@drush

Description

@drush

SDK you're using (please complete the following information):

  • Version 10.0.0

Is your feature request related to a problem? Please describe.
Serverless platforms (specifically Cloudflare Workers/Pages) may not support some of all of the 'http' functions. In the CF case, they do not fully support the HTTPS handling. (They do support the fetch variation).

Describe the solution you'd like
Enable xero-node to set the axios adapter to the 'fetch' adapter (which is now built-in) at configuration time. It may be necessary to add an addiitonal optional parameter to XeroClient to set this value. Alternatively, the whole project may prefer to use fetch by default in v11.

Describe alternatives you've considered

  1. There does not appear to be a way to override the axios adapter without explicit code changes
  2. Axios detects 'http' because CF mocks it, but CF does not fully implement it. This means, the http adapter is chosen as the default, but later functions fail.

Additional context
Quick code validation:

  1. run the xero-node tests: npm test (all pass)
  2. Add this to line 6 of the XeroClient.ts file: axios.defaults.adapter = 'fetch';
  3. Run tests again - 3 failures

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions