youtube.js
586 Bytes
var response = "IU";
var keyword =response + " music video";
console.log(keyword);
var request = require('request');
var cheerio = require('cheerio');
var options = { method: 'GET',
url: 'https://www.googleapis.com/youtube/v3/search',
qs:
{ key: 'AIzaSyA8-HR7V5cGIwWiBUWzKZsm5yzwrYc-4ys',
part: 'id',
maxResults: '1',
order: 'viewCount',
q: keyword,
type: 'video' },
};
request(options, function(error,result,body){
if(error) throw new Error(error);
var temp = body.replace('{','');
var temp1 = temp.split('\n');
console.log(temp1);
});