youtube.js
525 Bytes
var response = 'IU';
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: response,
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);
});