Skip to content

Commit

Permalink
fixed backoffice api client and fetcher (#834)
Browse files Browse the repository at this point in the history
* fix(backoffice-v2): fixed wrong options passed to api client and fetcher

* fix(*): pnpm-lock
  • Loading branch information
Omri-Levy authored Aug 14, 2023
1 parent 7f3ad48 commit ed13a31
Show file tree
Hide file tree
Showing 3 changed files with 487 additions and 19 deletions.
9 changes: 5 additions & 4 deletions apps/backoffice-v2/src/common/api-client/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ export const apiClient: IApiClient = async ({ endpoint, method, options, schema,
options: {
...options,
credentials: 'include',
headers: {
Authorization: `Api-Key ${env.VITE_API_KEY}`,
...(options?.headers ?? {}),
},
},
headers: {
Authorization: `Api-Key ${env.VITE_API_KEY}`,
'Content-Type': 'application/json',
...(options?.headers ?? {}),
},
schema,
...rest,
Expand Down
4 changes: 2 additions & 2 deletions apps/backoffice-v2/src/common/utils/fetcher/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface IFetcher {
method: typeof Method.POST | typeof Method.PUT | typeof Method.PATCH;
body?: TBody;
headers?: RequestInit['headers'];
options?: Omit<RequestInit, 'body'>;
options?: Omit<RequestInit, 'body' | 'headers'>;
timeout?: number;
schema: TZodSchema;
isBlob?: boolean;
Expand All @@ -21,7 +21,7 @@ export interface IFetcher {
url: string;
method: typeof Method.GET | typeof Method.DELETE;
headers?: RequestInit['headers'];
options?: Omit<RequestInit, 'body'>;
options?: Omit<RequestInit, 'body' | 'headers'>;
timeout?: number;
schema: TZodSchema;
}): Promise<z.infer<TZodSchema>>;
Expand Down
Loading

0 comments on commit ed13a31

Please sign in to comment.