Skip to content

Commit

Permalink
feat(projects): @sa/axios: add qs stringify for params
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jan 22, 2024
1 parent e9b1571 commit 6ee5a21
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
6 changes: 5 additions & 1 deletion packages/axios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"dependencies": {
"@sa/utils": "workspace:*",
"axios": "1.6.5",
"axios-retry": "4.0.0"
"axios-retry": "4.0.0",
"qs": "6.11.2"
},
"devDependencies": {
"@types/qs": "6.9.11"
}
}
6 changes: 5 additions & 1 deletion packages/axios/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CreateAxiosDefaults } from 'axios';
import type { IAxiosRetryConfig } from 'axios-retry';
import { stringify } from 'qs';
import { isHttpSuccess } from './shared';
import type { RequestOption } from './type';

Expand Down Expand Up @@ -35,7 +36,10 @@ export function createAxiosConfig(config?: Partial<CreateAxiosDefaults>) {
headers: {
'Content-Type': 'application/json'
},
validateStatus: isHttpSuccess
validateStatus: isHttpSuccess,
paramsSerializer: params => {
return stringify(params);
}
};

Object.assign(axiosConfig, config);
Expand Down
30 changes: 18 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ee5a21

Please sign in to comment.