21 lines
403 B
TypeScript
21 lines
403 B
TypeScript
import { $axios } from "@/lib/axios";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
export type User = {
|
|
id: number;
|
|
email: string;
|
|
login: string;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
export const useUserQuery = () => {
|
|
return useQuery({
|
|
queryKey: ["user"],
|
|
queryFn: async () => {
|
|
const resp = await $axios.get<User>("/user");
|
|
return resp.data;
|
|
},
|
|
});
|
|
};
|