Use nodejs and require to download an image but ‘You need to enable JavaScript to run this app.’ error

I’m trying to automate the image download from my company dashboard.
My first idea was to use require.
I found a script that works perfectly: Downloading images with node.js
I get the following code:

var fs = require('fs'),
request = require('request');

var download = function(uri, filename, callback){
  request.head(uri, function(err, res, body){
    console.log('content-type:', res.headers['content-type']);
    console.log('content-length:', res.headers['content-length']);

    request(uri).pipe(fs.createWriteStream(filename)).on('close', callback);
  });
};

download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function(){
  console.log('done');
});

This code works without error and downloads the example image.
I modify it to add the headers (token,..) and the link of my image.
The script runs without errors but my contents are undefined:

content-type: undefined
content-length: undefined
done

When I look at the image created by the script, it contains html with the error “You need to enable JavaScript to run this app.”.
I have no idea how I can get around this problem. Does anyone have a tip?