JSFiddle - React, Tailwind, and code Playground

by velo_ninja

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>YouTube API Example</title>
  <!-- Include the fetch polyfill -->
  <script src="https://unpkg.com/[email protected]/dist/fetch.umd.js"></script>
  <style>
    /* Your existing styles... */

    /* Style for the most popular videos title */
    #videoContainer p:first-child {
      font-weight: bold;
      font-size: 1.5em;
      margin-bottom: 10px;
    }

    /* Style for the video entry */
    .videoEntry {
      position: relative;
      margin-bottom: 20px;
      border: 1px solid #ccc;
      border-radius: 5px;
      box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
      overflow: hidden;
    }

    /* Style for the thumbnail image */
    .thumbnail {
      max-width: 100%;
      height: auto;
      float: left;
    }

    /* Style for the title and ID container */
    .titleContainer {
      padding: 10px;
      overflow: hidden;
    }

    /* Style for the title */
    .title {
      font-weight: bold;
      font-size: 1.2em;
      font-family: 'Arial', sans-serif; /* Change to your preferred font family */
      margin-bottom: 5px;
    }

    /* Style for the video ID */
    .videoId {
      color: #888;
      font-size: 0.8em;
    }

    button {
      position: absolute;
      bottom: 10px;
      left: 50%;
      transform: translateX(-150%);
      padding: 10px;
      font-size: 16px;
    }
  </style>
</head>
<body>

  <div id="mainDiv">
    <div id="videoContainer"></div>
    <button onclick="logAndDisplayVideos()">Click here to log and display videos</button>
  </div>

  <script>
    // Replace 'YOUR_API_KEY' with your actual YouTube Data API key
    const apiKey = 'AIzaSyC-D9kO7XOMLu_O9fZcl5RCPHg_uv8oGnM';

    // Replace 'Wix' with your search query
    const searchQuery = 'Wix';

    // Set the maximum number of results (max: 50)
    const maxResults = 50;

    function getVideoStatistics(videoId) {
     ...

JavaScript

AIzaSyC-D9kO7XOMLu_O9fZcl5RCPHg_uv8oGnM