SaveThePDF(url, filename) { const writeFile = denodeify(fs.writeFile); const requestPromised = denodeify(request.defaults({ 'gzip': true, headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*\/*;q=0.8', } }), function(err, httpResponse, body) { // Convert 3 paramters to 2 return [err, {httpResponse: httpResponse, body: body}]; }); return requestPromised({ url: url, method: 'post', encoding: 'binary' }).then ( (response) => { return writeFile(filename, response.body, 'ascii'); }); }