Skip to content

Commit 3ed205a

Browse files
authored
SWI-3723 Fix Axios Typing with 1.6.0 (#63)
* SWI-3723 Fix Axios Typing with 1.6.0 * update package json to fix import issue
1 parent 374483e commit 3ed205a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
"lodash.flatmap": "^4.5.0",
4949
"tiny-warning": "^1.0.3"
5050
},
51+
"jest": {
52+
"moduleNameMapper": {
53+
"axios": "axios/dist/node/axios.cjs"
54+
}
55+
},
5156
"bugs": {
5257
"email": "[email protected]"
5358
}

src/http/httpClient.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
55
*/
66

7-
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
7+
import axios, { AxiosHeaders, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
88
import isNode from 'detect-node';
99
import FormData from 'form-data';
1010
import { isBlob } from '../apiHelper';
@@ -91,14 +91,14 @@
9191
}
9292

9393
newRequest.data = form;
94-
mergeHeaders(newRequest.headers || {} , form.getHeaders());
94+
mergeHeaders(newRequest.headers as AxiosHeaders || {} , form.getHeaders());
9595
} else if (
9696
requestBody?.type === 'form-data' ||
9797
requestBody?.type === 'form'
9898
) {
9999
// Create form-urlencoded request
100100
setHeader(
101-
newRequest.headers || {},
101+
newRequest.headers as AxiosHeaders || {},
102102
CONTENT_TYPE_HEADER,
103103
FORM_URLENCODED_CONTENT_TYPE
104104
);
@@ -112,7 +112,7 @@
112112
// Otherwise, use the content type if available.
113113
contentType = requestBody.content.options.contentType;
114114
}
115-
setHeaderIfNotSet(newRequest.headers || {}, CONTENT_TYPE_HEADER, contentType);
115+
setHeaderIfNotSet(newRequest.headers as AxiosHeaders || {}, CONTENT_TYPE_HEADER, contentType);
116116
newRequest.data = requestBody.content.file;
117117
}
118118
else if (requestBody && typeof(requestBody['type']) !== 'undefined') {
@@ -139,7 +139,7 @@
139139
public convertHttpResponse(resp: AxiosResponse): HttpResponse {
140140
return {
141141
body: resp.data,
142-
headers: resp.headers,
142+
headers: resp.headers as AxiosHeaders,
143143
statusCode: resp.status,
144144
};
145145
}
@@ -185,4 +185,4 @@
185185
return new AbortError('The HTTP call was aborted.');
186186
}
187187
}
188-
188+

0 commit comments

Comments
 (0)