Estado inicial: frontend React + backend Laravel

This commit is contained in:
Xavier Oliveira
2026-05-15 15:57:54 +01:00
commit 41c5f87d5b
216 changed files with 29916 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import type { User } from "../types";
interface ApiUserResponse {
message: string;
data: User;
errors: null | unknown;
}
export function useGetCurrentUser() {
async function getCurrentUser(): Promise<ApiUserResponse> {
const response = await fetch("http://127.0.0.1:8000/api/me", {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("token")}`
},
});
const currentUser = await response.json() as ApiUserResponse;
return currentUser;
}
return { getCurrentUser };
}