23 lines
717 B
TypeScript
23 lines
717 B
TypeScript
import type { ApiErrorResponse, Video } from "../types";
|
|
|
|
export function useNextVideos() {
|
|
async function getNextVideos() {
|
|
const response = await fetch("http://127.0.0.1:8000/api/next-videos", {
|
|
method: "GET",
|
|
headers: {
|
|
Accept: "application/json",
|
|
"Content-Type": "application/json",
|
|
Authorization: `Bearer ${localStorage.getItem("token")}`
|
|
},
|
|
});
|
|
const data = await response.json();
|
|
if (response.ok) {
|
|
return {
|
|
videos: data.data as Video[],
|
|
};
|
|
} else {
|
|
return data as ApiErrorResponse;
|
|
}
|
|
}
|
|
return { getNextVideos };
|
|
} |