1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import type { User } from "@/types/authApi";
export const authApi = createApi({
reducerPath: "authApi",
baseQuery: fetchBaseQuery({
baseUrl: "/auth",
credentials: "include", // sends the httpOnly cookie
}),
tagTypes: ["User"],
endpoints: (builder) => ({
getMe: builder.query<User, void>({
query: () => "/session/",
providesTags: ["User"],
}),
// logout: builder.mutation({
// query: () => ({ url: "/de-session", method: "POST" }),
// invalidatesTags: ["User"],
// }),
}),
});
// export const { useGetMeQuery, useLogoutMutation } = authApi;
export const { useGetMeQuery } = authApi;
|