Google Drive API drive.files.get NODEJS

0

Hello, I'm trying to run the function below, and all parameters are valid.

function getFiles(fileId, auth){
  const drive = google.drive({version: 'v3', auth});
  var dest = fs.createWriteStream('pppp.pdf');
  drive.files.get({
    fileId: '1nX04lq5s7MWDlMpyO9ApDn95VMngNub4',
    alt: 'media'

  })  
  .on('end', function () {
    console.log('Done');
  })
  .on('error', function (err) {
    console.log('Error during download', err);
  })
  .pipe(dest);
}

But when I run, I'm having function return as undifined , which results in the following error:

TypeError: Cannot read property 'on' of undefined

Could anyone help me?

    
asked by anonymous 27.07.2018 / 19:11

0 answers