Skip to content

Commit

Permalink
ts fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
freddi301 committed Nov 18, 2024
1 parent 5048596 commit e8077c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
41 changes: 20 additions & 21 deletions ts/fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type RequestConfig<TData = unknown> = {
headers?: HeadersInit;
};

export type ResponseConfig<TData = unknown, TError = unknown> = {
export type ResponseConfig<TData = unknown> = {
data: TData;
status: number;
statusText: string;
Expand All @@ -29,27 +29,26 @@ export async function fetchClient<
TData,
TError = unknown,
TVariables = unknown
>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData, TError>> {

const response = await (global as any).fetch(
`${Config.API_URL_PREFIX}${config.baseURL}${config.url}`,
{
method: config.method.toUpperCase(),
body: JSON.stringify(config.data),
signal: config.signal,
headers: {
Authorization: `Bearer ${sessionTokenSelector(store.getState())}`,
...config.headers
}
>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> {
const response = await (global as any).fetch(
`${Config.API_URL_PREFIX}${config.baseURL}${config.url}`,
{
method: config.method.toUpperCase(),
body: JSON.stringify(config.data),
signal: config.signal,
headers: {
Authorization: `Bearer ${sessionTokenSelector(store.getState())}`,
...config.headers
}
);
const data = await response.json();
return {
data,
status: response.status,
statusText: response.statusText
};
}
}
);
const data = await response.json();
void null as TError;
return {
data,
status: response.status,
statusText: response.statusText
};
}

export default fetchClient;
2 changes: 1 addition & 1 deletion ts/react-query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function useFocusNotifyOnChangeProps(
}

/** https://tanstack.com/query/latest/docs/framework/react/react-native#disable-queries-on-out-of-focus-screens */
export function useQueryFocusAware(notifyOnChangeProps?: NotifyOnChangeProps) {
export function useQueryFocusAware() {
const focusedRef = useFocusedRef();
return () => focusedRef.current;
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"exclude": [
"android",
"ios",
"node_modules"
"node_modules",
"fetch-sdk"
]
}

0 comments on commit e8077c8

Please sign in to comment.