mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-18 21:44:08 +01:00
23 lines
537 B
TypeScript
23 lines
537 B
TypeScript
import axios from "axios";
|
|
import axiosInstance from "./config";
|
|
import { User } from "@/types";
|
|
|
|
export interface UserDataOutput {
|
|
user: User;
|
|
}
|
|
|
|
/**
|
|
* Fetches the data for the authenticated user.
|
|
*/
|
|
export async function fetchUserMe(): Promise<UserDataOutput> {
|
|
try {
|
|
const response = await axiosInstance.get("/user/me");
|
|
return response.data;
|
|
} catch (error: any) {
|
|
if (axios.isAxiosError(error)) {
|
|
throw new Error(error.response?.data?.message || "Failed to fetch user data.");
|
|
}
|
|
throw error;
|
|
}
|
|
}
|