36 lines
821 B
TypeScript
36 lines
821 B
TypeScript
import api from './api';
|
|
|
|
export interface Video {
|
|
id: string;
|
|
title: string;
|
|
doctor: string;
|
|
duration: string;
|
|
thumbnail: string;
|
|
videoUrl: string;
|
|
description: string;
|
|
viewsCount?: number;
|
|
isFeatured?: boolean;
|
|
}
|
|
|
|
export const videoService = {
|
|
getVideos: async (params?: { featured?: boolean; limit?: number; search?: string }) => {
|
|
try {
|
|
const res = await api.get('/videos', { params });
|
|
return res.data.data || res.data || [];
|
|
} catch (error) {
|
|
console.error('Failed to fetch videos from API:', error);
|
|
return [];
|
|
}
|
|
},
|
|
|
|
getVideoById: async (id: string) => {
|
|
try {
|
|
const res = await api.get(`/videos/${id}`);
|
|
return res.data;
|
|
} catch (error) {
|
|
console.error('Failed to fetch video details:', error);
|
|
return null;
|
|
}
|
|
}
|
|
};
|