Skip to content

Commit 01ec1cc

Browse files
authored
use instance axios, not global (#2846)
1 parent cfd9ed8 commit 01ec1cc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/helper/REST.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class REST extends Helper {
5959

6060
this.options = { ...this.options, ...config };
6161
this.headers = { ...this.options.defaultHeaders };
62-
axios.defaults.headers = this.options.defaultHeaders;
62+
this.axios = axios.create();
63+
this.axios.defaults.headers = this.options.defaultHeaders;
6364
}
6465

6566
static _checkRequirements() {
@@ -77,7 +78,7 @@ class REST extends Helper {
7778
*/
7879
async _executeRequest(request) {
7980
const _debugRequest = { ...request };
80-
axios.defaults.timeout = request.timeout || this.options.timeout;
81+
this.axios.defaults.timeout = request.timeout || this.options.timeout;
8182

8283
if (this.headers && this.headers.auth) {
8384
request.auth = this.headers.auth;
@@ -102,7 +103,7 @@ class REST extends Helper {
102103

103104
let response;
104105
try {
105-
response = await axios(request);
106+
response = await this.axios(request);
106107
} catch (err) {
107108
if (!err.response) throw err;
108109
this.debugSection('Response', `Response error. Status code: ${err.response.status}`);

0 commit comments

Comments
 (0)