1
1
2
2
'use strict'
3
3
4
- const axios = require ( 'axios ' )
4
+ const extrareqp2 = require ( 'extrareqp2 ' )
5
5
const AuthStrategy = require ( './auth_strategies/strategy' )
6
6
const constants = require ( '../constants' )
7
7
const logger = require ( 'debug' ) ( 'kmjs:network' )
@@ -25,7 +25,7 @@ module.exports = class NetworkWrapper {
25
25
}
26
26
this . km = km
27
27
this . _queue = [ ]
28
- this . _axios = axios . create ( opts )
28
+ this . _extrareqp2 = extrareqp2 . create ( opts )
29
29
this . _websockets = [ ]
30
30
this . _endpoints = new Map ( )
31
31
this . _bucketFilters = new Map ( )
@@ -70,7 +70,7 @@ module.exports = class NetworkWrapper {
70
70
}
71
71
}
72
72
73
- this . _axios . interceptors . response . use (
73
+ this . _extrareqp2 . interceptors . response . use (
74
74
response => {
75
75
updateApiDateLag ( response )
76
76
return response
@@ -108,7 +108,7 @@ module.exports = class NetworkWrapper {
108
108
if ( ! bucketID ) return Promise . reject ( new Error ( `Missing argument : bucketID` ) )
109
109
110
110
if ( ! this . _endpoints . has ( bucketID ) ) {
111
- const promise = this . _axios . request ( {
111
+ const promise = this . _extrareqp2 . request ( {
112
112
url : `/api/bucket/${ bucketID } ` ,
113
113
method : 'GET' ,
114
114
headers : {
@@ -179,7 +179,7 @@ module.exports = class NetworkWrapper {
179
179
}
180
180
httpOpts . headers . Authorization = `Bearer ${ this . tokens . access_token } `
181
181
182
- this . _axios . request ( httpOpts )
182
+ this . _extrareqp2 . request ( httpOpts )
183
183
. then ( successNext )
184
184
. catch ( ( error ) => {
185
185
let response = error . response
@@ -207,7 +207,7 @@ module.exports = class NetworkWrapper {
207
207
// then we can rebuffer the request
208
208
loggerHttp ( `Re-buffering call to ${ httpOpts . url } since authenticated now` )
209
209
httpOpts . headers . Authorization = `Bearer ${ this . tokens . access_token } `
210
- return this . _axios . request ( httpOpts ) . then ( successNext ) . catch ( next )
210
+ return this . _extrareqp2 . request ( httpOpts ) . then ( successNext ) . catch ( next )
211
211
} )
212
212
} )
213
213
}
@@ -247,8 +247,8 @@ module.exports = class NetworkWrapper {
247
247
248
248
loggerHttp ( `Registered new access_token : ${ data . access_token } ` )
249
249
this . _websockets . forEach ( websocket => websocket . updateAuthorization ( data . access_token ) )
250
- this . _axios . defaults . headers . common [ 'Authorization' ] = `Bearer ${ data . access_token } `
251
- this . _axios . request ( {
250
+ this . _extrareqp2 . defaults . headers . common [ 'Authorization' ] = `Bearer ${ data . access_token } `
251
+ this . _extrareqp2 . request ( {
252
252
url : '/api/bucket' ,
253
253
method : 'GET' ,
254
254
headers : {
0 commit comments