umami/hooks/useApi.js

14 lines
346 B
JavaScript
Raw Normal View History

2022-12-28 05:38:23 +00:00
import { useApi as nextUseApi } from 'next-basics';
import { getClientAuthToken } from 'lib/client';
2022-02-23 07:52:31 +00:00
import { useRouter } from 'next/router';
2022-02-26 23:53:45 +00:00
2022-12-28 05:38:23 +00:00
export function useApi() {
2022-02-23 07:52:31 +00:00
const { basePath } = useRouter();
2022-12-28 05:38:23 +00:00
const { get, post, put, del } = nextUseApi(getClientAuthToken(), basePath);
2022-02-23 07:52:31 +00:00
2022-12-28 05:38:23 +00:00
return { get, post, put, del };
2022-02-23 07:52:31 +00:00
}
2022-12-28 05:38:23 +00:00
export default useApi;