philbot9 / youtube-info

Fetch meta information about YouTube videos
ISC License
43 stars 20 forks source link

fetchVideoInfo doesn't return the informations #31

Closed Avngarde closed 4 years ago

Avngarde commented 4 years ago

Everything is printed out properly, yet when i try to return the info nothing is returned, i only see a whitespace.

` function YT_get_song_info(link){

let video_id = get_id_from_youtube_link(link);

let fetchVideoInfo = require('youtube-info');

fetchVideoInfo(video_id, function (err, videoInfo) {

    if (err) throw new Error(err);

    return(videoInfo);

});
philbot9 commented 4 years ago

Hi there,

Please review your code. As it stands it will not work.

A couple of pointers:

  1. I don't think calling return(videoInfo) as a function is intended.
  2. Returning the video info in the callback function will not output the results anywhere. You could use console.log(videoInfo) instead of the return to print the result to stdout.

Good luck!