- Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
To be able to have different axios configurations beyond axiosConfig (ie. interceptors) it should be possible to assign a an axios instance which will be used in place of the global axios, which remains the default.
One example of such use would be to use a separate logger and interceptors for logging WC requests.
`
let wcAxiosInstance = axios.create();
wcAxiosInstance.interceptors.request.use(req =>{wcApiLogger.debug(`Request ${req.method} ${req.url}`); wcApiLogger.debug(`Headers > ${JSON.stringify(req.headers)}`) return req}); wcAxiosInstance.interceptors.response.use(res =>{wcApiLogger.debug(`Response ${res.config.method} ${res.config.url} ${res.status}`); wcApiLogger.debug(`Headers < ${JSON.stringify(res.headers)}`) return res}); let wcApi = new WooCommerceRestApi({
url: ...,
consumerKey: ...,
consumerSecret: ...,
axiosInstance: wcAxiosInstance
});
`
hicreate and anoblet
Metadata
Metadata
Assignees
Labels
No labels