Skip to content

Commit

Permalink
fix: simplifyMethodFactory method未传进request
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed May 12, 2022
1 parent 93a74b4 commit 980f2d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion __test__/AxiosRequestTemplate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('AxiosRequestTemplate', () => {
test('simplifyMethodFactory', async () => {
const get = req.simplifyMethodFactory('get');
const post = req.simplifyMethodFactory('post');
expect.assertions(4);
expect.assertions(5);
// console.log((axios.create({ url: 'test' }) as any)(1, 2, 3), Req);
const res = await get<{ username: string; id: number }>('/user');
expect(res).toEqual({ code: 200, data: { username: 'get', id: 1 }, msg: 'success' });
Expand All @@ -91,6 +91,10 @@ describe('AxiosRequestTemplate', () => {
} catch (e) {
expect(e).toEqual({ code: 0, msg: '账号或密码错误' });
}

const res5 = await post('/user');

expect(res5).toEqual({ code: 200, data: { username: 'post', id: 2 }, msg: 'success' });
});

describe('AxiosWrapper Cache', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/AxiosRequestTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class AxiosRequestTemplate<CC extends CustomConfig = CustomConfig> {
data = {},
customConfig = {} as DynamicCustomConfig<CC, RC>,
) => {
const requestConfig: AxiosRequestConfig = {};
const requestConfig: AxiosRequestConfig = { method };
if (method === 'get') {
requestConfig.params = data;
} else {
Expand Down

0 comments on commit 980f2d0

Please sign in to comment.