mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 15:47:13 +01:00
Moved files around.
This commit is contained in:
parent
60cd869407
commit
2cd38f1306
35 changed files with 45 additions and 45 deletions
20
src/components/hooks/useApi.ts
Normal file
20
src/components/hooks/useApi.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import * as reactQuery from '@tanstack/react-query';
|
||||
import { useApi as nextUseApi } from 'next-basics';
|
||||
import { getClientAuthToken } from 'lib/client';
|
||||
import { SHARE_TOKEN_HEADER } from 'lib/constants';
|
||||
import useStore from 'store/app';
|
||||
|
||||
const selector = (state: { shareToken: { token?: string } }) => state.shareToken;
|
||||
|
||||
export function useApi() {
|
||||
const shareToken = useStore(selector);
|
||||
|
||||
const { get, post, put, del } = nextUseApi(
|
||||
{ authorization: `Bearer ${getClientAuthToken()}`, [SHARE_TOKEN_HEADER]: shareToken?.token },
|
||||
process.env.basePath,
|
||||
);
|
||||
|
||||
return { get, post, put, del, ...reactQuery };
|
||||
}
|
||||
|
||||
export default useApi;
|
||||
Loading…
Add table
Add a link
Reference in a new issue