Add function to modify base response
This commit is contained in:
parent
9bd12df8f6
commit
fe043d1823
1 changed files with 10 additions and 0 deletions
10
src/renderer/api/utils.ts
Normal file
10
src/renderer/api/utils.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import { AxiosHeaders } from 'axios';
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
// Since ts-rest client returns a strict response type, we need to add the headers to the body object
|
||||||
|
export const resultWithHeaders = <ItemType extends z.ZodTypeAny>(itemSchema: ItemType) => {
|
||||||
|
return z.object({
|
||||||
|
data: itemSchema,
|
||||||
|
headers: z.instanceof(AxiosHeaders),
|
||||||
|
});
|
||||||
|
};
|
Reference in a new issue