feat(projects): @sa/axios: add qs stringify for params

This commit is contained in:
Soybean
2024-01-23 00:30:43 +08:00
parent b3779a6313
commit 2400c02655
3 changed files with 28 additions and 14 deletions

View File

@ -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"
}
}

View File

@ -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';
@ -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);