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,24 @@
import type { ApiErrorResponse, Video } from "../types";
export function useGetVideos() {
async function getVideos(searchQuery?: string) {
const response = await fetch(`http://127.0.0.1:8000/api/videos?search=${encodeURIComponent(searchQuery ?? "")}`, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${localStorage.getItem("token")}`
},
});
const data = await response.json();
if (response.ok) {
return data.data as Video[];
} else {
return (data as ApiErrorResponse);
}
}
return { getVideos };
}