From bb39d63d3702aa32fbb6c21c475632b231abc05f Mon Sep 17 00:00:00 2001 From: Daniel Pyrathon Date: Mon, 10 Aug 2020 15:12:16 -0700 Subject: [PATCH] fixed class instantiation issue --- packages/asset-swapper/src/utils/quote_requestor.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/asset-swapper/src/utils/quote_requestor.ts b/packages/asset-swapper/src/utils/quote_requestor.ts index 36b505c417..6b4e6df53f 100644 --- a/packages/asset-swapper/src/utils/quote_requestor.ts +++ b/packages/asset-swapper/src/utils/quote_requestor.ts @@ -10,6 +10,11 @@ import { Agent as HttpsAgent } from 'https'; import { constants } from '../constants'; import { MarketOperation, RfqtMakerAssetOfferings, RfqtRequestOpts } from '../types'; +const httpClient: AxiosInstance = Axios.create({ + httpAgent: new HttpAgent({ keepAlive: true }), + httpsAgent: new HttpsAgent({ keepAlive: true }), +}); + /** * Request quotes from RFQ-T providers */ @@ -87,10 +92,6 @@ export type LogFunction = (obj: object, msg?: string, ...args: any[]) => void; export class QuoteRequestor { private readonly _schemaValidator: SchemaValidator = new SchemaValidator(); - private readonly _httpClient: AxiosInstance = Axios.create({ - httpAgent: new HttpAgent({ keepAlive: true }), - httpsAgent: new HttpsAgent({ keepAlive: true }), - }); constructor( private readonly _rfqtAssetOfferings: RfqtMakerAssetOfferings, @@ -322,7 +323,7 @@ export class QuoteRequestor { throw new Error(`Unexpected quote type ${quoteType}`); } })(); - const response = await this._httpClient.get(`${url}/${quotePath}`, { + const response = await httpClient.get(`${url}/${quotePath}`, { headers: { '0x-api-key': options.apiKey }, params: requestParams, timeout: options.makerEndpointMaxResponseTimeMs,