如何从httpreq函数返回变量?
function getTrailerYoutube(movieName){
var getVideoList = 'https://www.googleapis.com/youtube/v3/search?part=snippet&q='
+ movieName + '+Trailer&type=video&videoDuration=short&key=<mykey>'
httpreq.get(getVideoList, function (err, res){
if (err) return console.log(err);
var moviefront = JSON.parse(movieback);
var result = moviefront.video.videoId
return result
});
}
console.log(result); //undefined