Skip to content

Commit 057f81b

Browse files
committed
fix: support query, body and params requests
1 parent e52b9fb commit 057f81b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: src/generateHooks.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ export const createHook = ({
436436
${headerParam}
437437
${paramsTypes}
438438
};
439-
// TEST1
440439
441440
export const ${fetchName} = async (${bodyProps}: ${componentName}Params) => {
442441
${generateBodyProps()}
@@ -447,7 +446,19 @@ export const createHook = ({
447446
}
448447

449448
if (requestBodyComponent && paramsInPath.length && queryParam && !headerParam) {
450-
output += `// TODO: NOT SUPPORTED requestBodyComponent && paramsInPath && queryParam)`;
449+
output += `
450+
export type ${componentName}Params = ${body} & {
451+
${headerParam}
452+
${paramsTypes}
453+
};
454+
455+
export const ${fetchName} = async (${bodyProps}: ${componentName}Params) => {
456+
${generateBodyProps()}
457+
const params = {${generateProps(queryParams)}}
458+
const result = await api.${verb}<${responseTypes}>(\`${route.replace(/\{/g, '{props.')}\`, body, {params})
459+
return result.data
460+
}
461+
`;
451462
}
452463

453464
if (requestBodyComponent && paramsInPath.length && queryParam && headerParam) {

0 commit comments

Comments
 (0)