Skip to content

Commit

Permalink
woocommerce#100 Added configuration property for setting axios instance
Browse files Browse the repository at this point in the history
  • Loading branch information
lbroman committed Jun 20, 2021
1 parent 70c9019 commit f839c08
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit f839c08

Please sign in to comment.