Skip to content

Commit

Permalink
SWI-3723 Fix Axios Typing with 1.6.0 (#63)
Browse files Browse the repository at this point in the history
* SWI-3723 Fix Axios Typing with 1.6.0

* update package json to fix import issue
  • Loading branch information
ckoegel authored Nov 7, 2023
1 parent 374483e commit 3ed205a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"lodash.flatmap": "^4.5.0",
"tiny-warning": "^1.0.3"
},
"jest": {
"moduleNameMapper": {
"axios": "axios/dist/node/axios.cjs"
}
},
"bugs": {
"email": "support@bandwidth.com"
}
Expand Down
12 changes: 6 additions & 6 deletions src/http/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
*/

import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import axios, { AxiosHeaders, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import isNode from 'detect-node';
import FormData from 'form-data';
import { isBlob } from '../apiHelper';
Expand Down Expand Up @@ -91,14 +91,14 @@
}

newRequest.data = form;
mergeHeaders(newRequest.headers || {} , form.getHeaders());
mergeHeaders(newRequest.headers as AxiosHeaders || {} , form.getHeaders());
} else if (
requestBody?.type === 'form-data' ||
requestBody?.type === 'form'
) {
// Create form-urlencoded request
setHeader(
newRequest.headers || {},
newRequest.headers as AxiosHeaders || {},
CONTENT_TYPE_HEADER,
FORM_URLENCODED_CONTENT_TYPE
);
Expand All @@ -112,7 +112,7 @@
// Otherwise, use the content type if available.
contentType = requestBody.content.options.contentType;
}
setHeaderIfNotSet(newRequest.headers || {}, CONTENT_TYPE_HEADER, contentType);
setHeaderIfNotSet(newRequest.headers as AxiosHeaders || {}, CONTENT_TYPE_HEADER, contentType);
newRequest.data = requestBody.content.file;
}
else if (requestBody && typeof(requestBody['type']) !== 'undefined') {
Expand All @@ -139,7 +139,7 @@
public convertHttpResponse(resp: AxiosResponse): HttpResponse {
return {
body: resp.data,
headers: resp.headers,
headers: resp.headers as AxiosHeaders,
statusCode: resp.status,
};
}
Expand Down Expand Up @@ -185,4 +185,4 @@
return new AbortError('The HTTP call was aborted.');
}
}


0 comments on commit 3ed205a

Please sign in to comment.