src/components/VideoPlayer/VideoPlayer.js
/*****Function*****
     * parameters: video - details of a video
     * Info: calls an api to get all properties of video and display
    */
Function
parameters: video - details of a video
Info: calls an api to get all properties of video and display
Function parameters : video - details of a video Info : calls an api to get all properties of video and display
async function createVideoInfo (video) {
        const snippet = video.snippet;
        const stats = video.statistics;
        const channelId = snippet.channelId;
        const response = await axios
                              .get(`https://www.googleapis.com/youtube/v3/channels?part=snippet%2C%20statistics&id=${channelId}&key=${process.env.REACT_APP_YOUTUBE_API_KEY}`)
        const channelImage = response.data.items[0].snippet.thumbnails.medium.url;
        const subs = response.data.items[0].statistics.subscriberCount;
        const publishedDate = new Date(snippet.publishedAt).toLocaleDateString('en-GB', {  
                                                                day : 'numeric',
                                                                month : 'short',
                                                                year : 'numeric'
                                                            });
        const title = snippet.title;
        const description = snippet.description;
        const channelTitle = snippet.channelTitle;
        setVideoInfo({
            title,
            description,
            publishedDate,
            channelTitle,
            channelImage,
        });
        setIsLoading(false);
    }
async function createVideoInfo ( video ) { const snippet = video . snippet ; const stats = video . statistics ; const channelId = snippet . channelId ; const response = await axios . get ( ` ${ channelId } ${ process . env . REACT_APP_YOUTUBE_API_KEY } ` ) const channelImage = response . data . items [ 0 ] . snippet . thumbnails . medium . url ; const subs = response . data . items [ 0 ] . statistics . subscriberCount ; const publishedDate = new Date ( snippet . publishedAt ) . toLocaleDateString ( 'en-GB' , { day : 'numeric' , month : 'short' , year : 'numeric' } ) ; const title = snippet . title ; const description = snippet . description ; const channelTitle = snippet . channelTitle ; setVideoInfo ( { title , description , publishedDate , channelTitle , channelImage , } ) ; setIsLoading ( false ) ; }
Function
 parameters: video - details of a video
 Info: calls an api to get all properties of video and display
Function parameters : video - details of a video Info : calls an api to get all properties of video and display