{"size": 2174, "ext": "js", "max_stars_repo_path": "API/src/api/routes/youtubeapi.js", "max_stars_repo_name": "fazemodz/BackEndTests", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "API/src/api/routes/youtubeapi.js", "max_issues_repo_name": "fazemodz/BackEndTests", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "API/src/api/routes/youtubeapi.js", "max_forks_repo_name": "fazemodz/BackEndTests", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.4461538462, "max_line_length": 172, "alphanum_fraction": 0.6191352346}
const express = require('express');
const router = express.Router();
const axios = require('axios');
const util = require('util'); 
const decycle = require('json-decycle')
let config = {
    headers: {
        'Accept': 'application/json'
    }
}
router.get('/getvideostats', (req, res)=>{
    res.json({
        message: "Please use / and a videoID"
    })
})
router.get('/getvideostats/:videoID', (req, res)=>{
    axios.get(`https://youtube.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id=${req.params.videoID}&key=${process.env.Youtube_API_Key}`)
    .then(function (response) {
        /*
            Saves the response data from youtube in a new variable, as 
            axios requires us to send response.data to get the request data.
        */
        let SendData = response.data
        //sends the data to the user
        res.status(200).send(response.data)
        
      })
      .catch(function (error) {
        
        console.log(error);
      })
      
    
})
router.get('/getvideostats/stringver/:videoID', (req, res)=>{
    axios.get(`https://youtube.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id=${req.params.videoID}&key=${process.env.Youtube_API_Key}`)
    .then(function (response) {
        //sends the data to the user
        res.status(200).send(JSON.stringify(response.data))
        console.log(response.data);
      })
      .catch(function (error) {
        
        console.log(error);
      })
})
router.get('/getchannelstats/:channelID', (req, res)=>{
    axios.get(`https://youtube.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=${req.params.channelID}&key=${process.env.Youtube_API_Key}`)
    .then(function (response) {
        /*
            Saves the response data from youtube in a new variable, as 
            axios requires us to send response.data to get the request data.
        */
        let SendData = response.data
        //sends the data to the user
        res.status(200).send(response.data)
        
      })
      .catch(function (error) {
        
        console.log(error);
      })
})

module.exports = router;