axios 请求参数去空
2022-12-26 本文已影响0人
深邃烟海
代码地址
const filterNullParams = (params, allValue) => {
Object.keys(params).filter(
key => (
params[key] === ''
|| params[key] === undefined
|| params[key] === null
)
&& delete params[key]
);
return params;
}
const queryList = () => {
const reqData = {
a: 1,
b: '',
c: -1,
}
axios.get('/api/openplatform/brand/kacompany/list', { params: filterNullParams(reqData) })
.then(res => res.data)
.then((res) => {
// 代码
});
}