Skip to content

Commit

Permalink
feat(axios): instantiate axios for every request
Browse files Browse the repository at this point in the history
EME-6117

Co-authored-by: Gabor Soos <gabor.soos@emarsys.com>
  • Loading branch information
Zsombor Margetan and Gabor Soos committed Apr 5, 2023
1 parent 2081c1f commit 35426ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('EscherRequest', function() {

beforeEach(function() {
requestOptions = new EscherRequestOption(serviceConfig.host, serviceConfig);
requestStub = sinon.stub(axios, 'request').resolves(createDummyResponse());
const instanceStub = axios.create();
sinon.stub(axios, 'create').returns(instanceStub);
requestStub = sinon.stub(instanceStub, 'request').resolves(createDummyResponse());
escherRequest = EscherRequest.create('key-id', 'secret', requestOptions);
});

Expand Down
4 changes: 3 additions & 1 deletion src/wrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe('RequestWrapper', function() {
let source: any;

beforeEach(function() {
requestGetStub = sinon.stub(axios, 'request');
const instanceStub = axios.create();
sinon.stub(axios, 'create').returns(instanceStub);
requestGetStub = sinon.stub(instanceStub, 'request');
requestGetStub.resolves(apiResponse);
source = {
token: cancelToken,
Expand Down
4 changes: 3 additions & 1 deletion src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export class RequestWrapper {
axiosOptions.httpsAgent = this.requestOptions.httpsAgent;
}

return axios
const client = axios.create();

return client
.request(axiosOptions)
.then(
response => this.transformResponse(response),
Expand Down

0 comments on commit 35426ce

Please sign in to comment.