const pattern = /\](,)\s{2,}?/gm
let res = inputData.rows.replace(pattern, (match, group1, offset, string) => "]")
.split(/\s{2,}/gm)
.map(x => JSON.parse(x));
res = res[0]; //reassign to scrape an array layer
let resultString = '';
for (let i = 0; i < res[0].length; i += 1) {
let cv = res[0][i];
if (cv.length === 0) resultString += ` ${res[1][i]}: ${inputData.rows[2][i]}\n`
else resultString += `${cv}\n ${res[1][i]}: ${res[2][i]}\n`;
}
output = {KPI: resultString};
问题
在Zapier Zap中,我正在从Google表格中提取数据,并使用JS进行美化,以便稍后发送电子邮件。我碰到了以下错误消息:
SyntaxError: Unexpected token ]
stringOfArraysToArrayOfArrays (eval at <anonymous> (/var/task/index.js:52:23), <anonymous>:22:52)
theFunction (eval at <anonymous> (/var/task/index.js:52:23), <anonymous>:29:18)
eval (eval at <anonymous> (/var/task/index.js:52:23), <anonymous>:51:20)
Domain.<anonymous> (/var/task/index.js:53:5)
Domain.run (domain.js:242:14)
module.exports.handler (/var/task/index.js:51:5)
我尝试过的
我已成功在不同环境中(从本地IDE,Repl.It IDE和设置为Node v6.3.1的在线IDE)将最新版本的Node的代码运行回Node v6.3.1。他们都清楚了。我还尝试清除所有ES6 +语法的代码(没有示例数据)
数据示例
let inputData = {
rows: `["Prioritized Tasks", "", "", "", "Operational Tasks", "", "", "", "Eight Dimensions", "", "", "", "", "", "", "", "Burn-Out", "", "", "", "", "", "", "", "", "", "Violations"],
}
犯罪嫌疑人X
相关分类