11
22'use strict'
33
4- const axios = require ( 'axios ' )
4+ const extrareqp2 = require ( 'extrareqp2 ' )
55const AuthStrategy = require ( './auth_strategies/strategy' )
66const constants = require ( '../constants' )
77const logger = require ( 'debug' ) ( 'kmjs:network' )
@@ -25,7 +25,7 @@ module.exports = class NetworkWrapper {
2525 }
2626 this . km = km
2727 this . _queue = [ ]
28- this . _axios = axios . create ( opts )
28+ this . _extrareqp2 = extrareqp2 . create ( opts )
2929 this . _websockets = [ ]
3030 this . _endpoints = new Map ( )
3131 this . _bucketFilters = new Map ( )
@@ -70,7 +70,7 @@ module.exports = class NetworkWrapper {
7070 }
7171 }
7272
73- this . _axios . interceptors . response . use (
73+ this . _extrareqp2 . interceptors . response . use (
7474 response => {
7575 updateApiDateLag ( response )
7676 return response
@@ -108,7 +108,7 @@ module.exports = class NetworkWrapper {
108108 if ( ! bucketID ) return Promise . reject ( new Error ( `Missing argument : bucketID` ) )
109109
110110 if ( ! this . _endpoints . has ( bucketID ) ) {
111- const promise = this . _axios . request ( {
111+ const promise = this . _extrareqp2 . request ( {
112112 url : `/api/bucket/${ bucketID } ` ,
113113 method : 'GET' ,
114114 headers : {
@@ -179,7 +179,7 @@ module.exports = class NetworkWrapper {
179179 }
180180 httpOpts . headers . Authorization = `Bearer ${ this . tokens . access_token } `
181181
182- this . _axios . request ( httpOpts )
182+ this . _extrareqp2 . request ( httpOpts )
183183 . then ( successNext )
184184 . catch ( ( error ) => {
185185 let response = error . response
@@ -207,7 +207,7 @@ module.exports = class NetworkWrapper {
207207 // then we can rebuffer the request
208208 loggerHttp ( `Re-buffering call to ${ httpOpts . url } since authenticated now` )
209209 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 )
211211 } )
212212 } )
213213 }
@@ -247,8 +247,8 @@ module.exports = class NetworkWrapper {
247247
248248 loggerHttp ( `Registered new access_token : ${ data . access_token } ` )
249249 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 ( {
252252 url : '/api/bucket' ,
253253 method : 'GET' ,
254254 headers : {
0 commit comments