Skip to content

Commit d9a4f4a

Browse files
committed
fix: remove custom params serializer
1 parent 9f31d20 commit d9a4f4a

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"fast-copy": "^2.1.7",
4747
"lodash.isplainobject": "^4.0.6",
4848
"lodash.isstring": "^4.0.1",
49-
"p-throttle": "^4.1.1",
50-
"qs": "^6.11.2"
49+
"p-throttle": "^4.1.1"
5150
},
5251
"devDependencies": {
5352
"@babel/cli": "^7.12.8",
@@ -66,7 +65,6 @@
6665
"@types/jest": "^29.2.2",
6766
"@types/lodash.isplainobject": "^4.0.6",
6867
"@types/lodash.isstring": "^4.0.6",
69-
"@types/qs": "^6.9.5",
7068
"@typescript-eslint/eslint-plugin": "^5.11.0",
7169
"@typescript-eslint/parser": "^5.11.0",
7270
"axios": "^1.4.0",

src/create-http-client.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { AxiosRequestHeaders } from 'axios'
22
import type { AxiosStatic } from 'axios'
33
import copy from 'fast-copy'
4-
import qs from 'qs'
54
import asyncToken from './async-token'
65

76
import rateLimitRetry from './rate-limit'
@@ -17,7 +16,7 @@ const HOST_REGEX = /^(?!\w+:\/\/)([^\s:]+\.?[^\s:]+)(?::(\d+))?(?!:)$/
1716
* @private
1817
* @param {AxiosStatic} axios - Axios library
1918
* @param {CreateHttpClientParams} options - Initialization parameters for the HTTP client
20-
* @return {ContentfulAxiosInstance} Initialized axios instance
19+
* @return {AxiosInstance} Initialized axios instance
2120
*/
2221
export default function createHttpClient(
2322
axios: AxiosStatic,
@@ -42,7 +41,6 @@ export default function createHttpClient(
4241
httpsAgent: false as const,
4342
timeout: 30000,
4443
throttle: 0,
45-
proxy: false as const,
4644
basePath: '',
4745
adapter: undefined,
4846
maxContentLength: 1073741824, // 1GB
@@ -91,11 +89,6 @@ export default function createHttpClient(
9189
headers: config.headers,
9290
httpAgent: config.httpAgent,
9391
httpsAgent: config.httpsAgent,
94-
paramsSerializer: {
95-
serialize: (params) => {
96-
return qs.stringify(params, { arrayFormat: 'repeat' })
97-
},
98-
},
9992
proxy: config.proxy,
10093
timeout: config.timeout,
10194
adapter: config.adapter,
@@ -107,6 +100,7 @@ export default function createHttpClient(
107100
requestLogger: config.requestLogger,
108101
retryOnError: config.retryOnError,
109102
}
103+
110104
const instance = axios.create(axiosOptions) as AxiosInstance
111105
instance.httpClientParams = options
112106

@@ -117,8 +111,8 @@ export default function createHttpClient(
117111
* and the version of the library comes from different places depending
118112
* on whether it's a browser build or a node.js build.
119113
* @private
120-
* @param {CreateHttpClientParams} httpClientParams - Initialization parameters for the HTTP client
121-
* @return {ContentfulAxiosInstance} Initialized axios instance
114+
* @param {CreateHttpClientParams} newParams - Initialization parameters for the HTTP client
115+
* @return {AxiosInstance} Initialized axios instance
122116
*/
123117
instance.cloneWithNewParams = function (
124118
newParams: Partial<CreateHttpClientParams>

src/error-handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import isPlainObject from 'lodash.isplainobject'
2-
import type { AxiosError } from 'axios'
32
import type { ContentfulErrorData } from './types'
43

54
/**
@@ -10,7 +9,7 @@ import type { ContentfulErrorData } from './types'
109
* and the expected error codes.
1110
* @private
1211
*/
13-
export default function errorHandler(errorResponse: AxiosError<ContentfulErrorData>): never {
12+
export default function errorHandler(errorResponse: any): never {
1413
const { config, response } = errorResponse
1514
let errorName
1615

0 commit comments

Comments
 (0)