// Get trending movies/TV app.get('/api/trending', async (req, res) => const mediaType = 'all', timeWindow = 'week' = req.query; try const response = await axios.get( $TMDB_BASE/trending/$mediaType/$timeWindow?api_key=$API_KEY ); res.json(response.data.results); catch (error) res.status(500).json( error: error.message );
);
return ( <div className="container mx-auto p-4"> <form onSubmit=handleSearch className="mb-6"> <input type="text" value=query onChange=(e) => setQuery(e.target.value) placeholder="Search movies, TV shows, people..." className="w-full p-3 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" /> <button type="submit" className="mt-2 bg-blue-600 text-white px-6 py-2 rounded-lg hover:bg-blue-700"> Search </button> </form> xxx-av20432
export const searchContent = (query, page = 1) => API.get( /search?query=$query&page=$page ); // Get trending movies/TV app
export const fetchTrending = (mediaType = 'all', timeWindow = 'week') => API.get( /trending?mediaType=$mediaType&timeWindow=$timeWindow ); // Get trending movies/TV app.get('/api/trending'
export const fetchDetails = (type, id) => API.get( /details/$type/$id ); import React from 'react'; const ContentCard = ( item, onClick ) => const imageUrl = item.poster_path ? https://image.tmdb.org/t/p/w500$item.poster_path : 'https://via.placeholder.com/500x750?text=No+Image';
return ( <div className="container mx-auto p-4"> <h1 className="text-3xl font-bold mb-6">🔥 Trending This Week</h1> <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-6"> trending.map((item) => ( <ContentCard key=item.id item=item onClick=() => navigate( /details/$item.media_type/$item.id ) /> )) </div> </div> ); ;