Add function to modify base response

This commit is contained in:
jeffvli 2023-04-23 02:09:25 -07:00
parent 9bd12df8f6
commit fe043d1823

10
src/renderer/api/utils.ts Normal file
View 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),
});
};