Skip to content

Commit 759a618

Browse files
authored
fix(utils): close #37, fix object params (#38)
1 parent 13624ab commit 759a618

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tua-api",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"description": "🏗 A common tool helps converting configs to api functions",
55
"main": "dist/TuaApi.cjs.js",
66
"module": "dist/TuaApi.esm.js",

src/utils/params.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ const getDefaultParamObj = ({
7070
}
7171
}
7272

73-
return { [key]: val }
73+
const returnVal = typeof val === 'object' ? '' : val
74+
75+
return { [key]: returnVal }
7476
}),
7577
reduce(merge, commonParams)
7678
)(params)

test/__tests__/utils.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ test('getDefaultParamObj', () => {
3838
commonParams: { c: '3' },
3939
})).toEqual({ b: '2', c: '3' })
4040

41+
expect(getDefaultParamObj({
42+
params: { a: { required: false } },
43+
})).toEqual({ a: '' })
44+
4145
expect(() => getDefaultParamObj({
4246
params: { b: { required: true } },
4347
apiName: 'steve',

0 commit comments

Comments
 (0)