src/components/RecommendedVideos/RecommendedVideos.js
/*****Function*****
     * parameters: videoItems - list of all video details in an array.
     * Info: calls an api to get details of each video available in videoItems parameter
    */
Function
parameters: videoItems - list of all video details in an array.
Info: calls an api to get details of each video available in videoItems parameter
Function parameters : videoItems - list of all video details in an array . Info : calls an api to get details of each video available in videoItems parameter
async function createVideoCards(videoItems) {
      let newVideoCards = [];
      for (const video of videoItems) {
        const videoId = video.contentDetails.videoId;
        const snippet = video.snippet;
        const channelId = snippet.channelId;
        const response = await axios
                              .get(`https://www.googleapis.com/youtube/v3/channels?part=snippet&id=UCL03ygcTgIbe36o2Z7sReuQ&key=${process.env.REACT_APP_YOUTUBE_API_KEY}`)
        const channelImage = response.data.items[0].snippet.thumbnails.medium.url;
        const title = snippet.title;
        const image = snippet.thumbnails.medium.url;
        const timestamp = DateTime.fromISO(snippet.publishedAt).toRelative();
        const channel = snippet.channelTitle;
        const description = snippet.description;
        newVideoCards.push({
          videoId,
          image,
          title,
          channel,
          timestamp,
          channelImage,
          description
        });
      };
      setVideoCards(newVideoCards);
      setIsLoading(false);
    }
async function createVideoCards ( videoItems ) { let newVideoCards = [ ] ; for ( const video of videoItems ) { const videoId = video . contentDetails . videoId ; const snippet = video . snippet ; const channelId = snippet . channelId ; const response = await axios . get ( ` ${ process . env . REACT_APP_YOUTUBE_API_KEY } ` ) const channelImage = response . data . items [ 0 ] . snippet . thumbnails . medium . url ; const title = snippet . title ; const image = snippet . thumbnails . medium . url ; const timestamp = DateTime . fromISO ( snippet . publishedAt ) . toRelative ( ) ; const channel = snippet . channelTitle ; const description = snippet . description ; newVideoCards . push ( { videoId , image , title , channel , timestamp , channelImage , description } ) ; } ; setVideoCards ( newVideoCards ) ; setIsLoading ( false ) ; }
Function
 parameters: videoItems - list of all video details in an array.
Function parameters : videoItems - list of all video details in an array .