I have been using this same code in Google Apps Scripts for quite some time and I have started receiving the following error:
SyntaxError: Unexpected token '<'
This just started happening this week after many months of running the script. I can still push the script through in Google by pressing run multiple times, but this is not scalable.
Here is the code and the error is attached the line of code that says eval(UrlFetchApp.fetch('https://cdn.rawgit.com/nodeca/pako/master/dist/pako.js').getContentText());
:
function mavenlink_raw(s1, options, report_id) {
// PULL MAVENLINK REPORT
var url = "https://api.mavenlink.com/api/v1/scheduled_jobs/insights_report_exports/"+report_id
var response = UrlFetchApp.fetch(url, options);
var dataSet = JSON.parse(response.getContentText());
var gzip = dataSet.latest_success.url
// CONVERT GZIP TO CSV
eval(UrlFetchApp.fetch('https://cdn.rawgit.com/nodeca/pako/master/dist/pako.js').getContentText());
var charData = UrlFetchApp.fetch(gzip).getContent();
var binData = [];
for (var i = 0; i < charData.length; i++) {
binData.push(charData[i] < 0 ? charData[i] + 256 : charData[i]);
}
var data = pako.inflate(binData);
var decoded = '';
for (var i = 0; i < data.length; i++) {
decoded += String.fromCharCode(data[i]);
}
var rows = Utilities.parseCsv(decoded);