diff --git a/index.d.ts b/index.d.ts index f107eb7..e1621e3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 { diff --git a/index.mjs b/index.mjs index e42f229..3b4a63a 100644 --- a/index.mjs +++ b/index.mjs @@ -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); } /**