Skip to content
Open
Show file tree
Hide file tree
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'
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down