'Const' is available.... Mozilla JS extensions (use moz) Error

I am using someone else's flow to download backups from my Hubitat Hub that then uploads to Dropbox. I just noticed it hasn't been working for 2 weeks and I have this error that is causing problem I believe.

I tried Googling the answer but am ignorant and this Function Node is not mine so I don't know how it works, just that it did.

Is there a layman's explanation of how to fix this because I don't understand the solutions that I have found so far.

Since it's been 2 weeks, I don't know remember what I might have changed at that time.

This is the flow:

[{"id":"bfbb0f64.5a3a7","type":"inject","z":"bc5f51dc.f17e7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":480,"wires":[["73619c2.2b3b464"]]},{"id":"73619c2.2b3b464","type":"http request","z":"bc5f51dc.f17e7","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.68.124/hub/backup","tls":"","persist":false,"proxy":"","authType":"","x":570,"y":420,"wires":[["a428e2f5.0cc0d"]]},{"id":"a428e2f5.0cc0d","type":"cheerio-function","z":"bc5f51dc.f17e7","name":"parse html cheerio","func":"const tableSelector = '#backup-table'\n\n//const cheerio = global.get('cheerio')\n//const $ = cheerio.load(msg.payload)\nconst options = {\n    rowForHeadings: 0,  // extract th cells from this row for column headings (zero-based)\n    ignoreHeadingRow: true, // Don't tread the heading row as data\n    ignoreRows: [],\n}\nconst rowEntries = []\nconst columnHeadings = []\n\n\n$(tableSelector).each(function(i, table) {\n    node.log(\"Something happened\");\n\n    var trs = $(table).find('tr')\n    \n    // Set up the column heading names\n    getColHeadings( $(trs[options.rowForHeadings]) )\n\n    // Process rows for data\n    $(table).find('tr').each(processRow)\n})\n\nif (rowEntries.length === 0)\n    return null;\n\nmsg.payload = {\n    fileName: rowEntries[rowEntries.length-1].Name\n}\n\nreturn msg\n\nfunction getColHeadings(headingRow) {\n    const alreadySeen = {}\n    \n    $(headingRow).find('th').each(function(j, cell) {\n        let tr = $(cell).text().trim()\n        \n        if ( alreadySeen[tr] ) {\n            let suffix = ++alreadySeen[tr]\n            tr = `${tr}_${suffix}`\n        } else {\n            alreadySeen[tr] = 1\n        }\n        \n        columnHeadings.push(tr)\n    })\n}\n\nfunction processRow(i, row) {\n    const rowJson = {}\n    \n    if ( options.ignoreHeadingRow && i === options.rowForHeadings ) return\n    // TODO: Process options.ignoreRows\n    \n    $(row).find('td').each(function(j, cell) {\n        rowJson[ columnHeadings[j] ] = $(cell).text().trim()\n    })\n    \n    // Skip blank rows\n    if (JSON.stringify(rowJson) !== '{}') rowEntries.push(rowJson)\n}\n","outputs":1,"noerr":0,"x":770,"y":420,"wires":[["70c9402d.b14ca","372ff87e.6e11e8"]]},{"id":"f44a90e0.ed333","type":"cronplus","z":"bc5f51dc.f17e7","name":"Run Backup","outputField":"payload","timeZone":"","commandResponseMsgOutput":"output1","outputs":1,"options":[{"topic":"AT115","payload":"","expression":"0 15 4 * * *","name":"AT115","expressionType":"cron","payloadType":"date","solarType":"all","solarEvents":"sunrise,sunset","location":""}],"x":230,"y":420,"wires":[["73619c2.2b3b464"]]},{"id":"70c9402d.b14ca","type":"http request","z":"bc5f51dc.f17e7","name":"","method":"GET","ret":"bin","paytoqs":"query","url":"http://192.168.68.124/hub/backupDB?","tls":"","persist":false,"proxy":"","authType":"basic","x":970,"y":420,"wires":[["430ec427.962dac","a200dcbf.2b174"]]},{"id":"372ff87e.6e11e8","type":"debug","z":"bc5f51dc.f17e7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":540,"wires":[]},{"id":"430ec427.962dac","type":"string","z":"bc5f51dc.f17e7","name":"","methods":[{"name":"strip","params":[{"type":"str","value":"attachment; filename="}]},{"name":"prepend","params":[{"type":"str","value":"/home/pi/Shared/Hubitat/BackupDBs/HubA--"}]}],"prop":"headers.content-disposition","propout":"filename","object":"msg","objectout":"msg","x":1170,"y":420,"wires":[["a2a57bab.118dc8"]]},{"id":"a200dcbf.2b174","type":"string","z":"bc5f51dc.f17e7","name":"","methods":[{"name":"strip","params":[{"type":"str","value":"attachment; filename="}]},{"name":"prepend","params":[{"type":"str","value":"/home/pi/Shared/Hubitat/BackupDBs/"}]}],"prop":"headers.content-disposition","propout":"filename","object":"msg","objectout":"msg","x":1170,"y":480,"wires":[[]]},{"id":"a2a57bab.118dc8","type":"file","z":"bc5f51dc.f17e7","name":"","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"binary","x":1310,"y":420,"wires":[["be68ea12.9b61d8","fe6277dd.998df8"]]},{"id":"be68ea12.9b61d8","type":"string","z":"bc5f51dc.f17e7","name":"","methods":[{"name":"strip","params":[{"type":"str","value":"attachment; filename="}]},{"name":"strip","params":[{"type":"str","value":"/home/pi/Shared/Hubitat/BackupDBs/"}]},{"name":"prepend","params":[{"type":"str","value":"HubA--"}]}],"prop":"headers.content-disposition","propout":"filename","object":"msg","objectout":"msg","x":1470,"y":420,"wires":[["20128ec4.779ac2"]]},{"id":"fe6277dd.998df8","type":"join-message","z":"bc5f51dc.f17e7","name":"Send to G7 Power","text":"The Hubitat Database A was successfully backed up.","title":"HUBITAT DB BACKUP HUB A","url":"","notificationicon":"","joinConfig":"a00a3cd.302dac","x":1510,"y":360,"wires":[[]]},{"id":"20128ec4.779ac2","type":"dropbox out","z":"bc5f51dc.f17e7","dropbox":"","filename":"","localFilename":"","name":"Upload","x":1620,"y":420,"wires":[]},{"id":"a00a3cd.302dac","type":"join-config","name":"Join MAIN","register":true}]

What version of Node-RED are you using?

Version 1.2.6

Ahh - I missed the fact this is a cheerio-function node - not the core Function node.

This is an issue with that node - not your code; especially if the code actually works when you try to run it.

The node is a clone of the core Function node, adding in some custom functionality from the Cheerio library. However it hasn't kept up to date with changes in the core Function node. It needs to be updated to tell its edit widget to support the newer JS syntax.

There isn't much for you to do, other than report the issue on the cheerio-function node's github repository: https://github.com/t4skforce/node-red-contrib-cheerio-function

Although given the repo has not received any updates for over 2 years, I don't know how far that will get.

Not the answer I was hoping for but an answer that will send me to find a new solution and stop grinding on this one. Thank you for quick response.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.