Skip to content

#100 Added configuration property for setting axios instance #101

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as OAuth from 'oauth-1.0a'
import {AxiosInstance} from "axios";

export declare type WooCommerceRestApiVersion =
| 'wc/v3'
@@ -36,6 +37,8 @@ export interface IWooCommerceRestApiOptions {
timeout?: number
/* Define the custom Axios config, also override this library options */
axiosConfig?: any
/* Define own axios instance which will be used, instead of use the default global static instance */
axiosInstance?: AxiosInstance
}

export interface IWooCommerceRestApiQuery {
3 changes: 2 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ export default class WooCommerceRestApi {
this.port = opt.port || "";
this.timeout = opt.timeout;
this.axiosConfig = opt.axiosConfig || {};
this.axiosInstance = opt.axiosInstance || axios;
}

/**
@@ -238,7 +239,7 @@ export default class WooCommerceRestApi {
// Allow set and override Axios options.
options = { ...options, ...this.axiosConfig };

return axios(options);
return this.axiosInstance.request(options);
}

/**