feat: paginate workshops and videos pages
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { ApiErrorResponse } from "../types";
|
||||
|
||||
export function useGetVideosLength() {
|
||||
async function getVideosLength() {
|
||||
try {
|
||||
const response = await fetch("http://127.0.0.1:8000/api/videos-length", {
|
||||
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.videos,
|
||||
videosWatched: data.data.videosWatched,
|
||||
};
|
||||
}
|
||||
|
||||
return data as ApiErrorResponse;
|
||||
|
||||
} catch (error) {
|
||||
return error as ApiErrorResponse;
|
||||
}
|
||||
}
|
||||
|
||||
return { getVideosLength };
|
||||
}
|
||||
Reference in New Issue
Block a user