Hi, I'm quite new to Java script and Node Red so looking for help with a hopefully simple but strange issue.
I have a function that create an array with 10 values that I store as a flow variable.
If I check the array_name.length I get 10 in return as expected.
But if I call up the variable in another function it becomes a nested array and array_name.length returns the value 1.
How can I call the array so that it is not nested?
Thanks
[{"id":"20bb0f7f9fab47a8","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"de7faf407b15924b","type":"function","z":"20bb0f7f9fab47a8","name":"","func":"var holidays = flow.get([\"holidays\"]) || [];\nvar x = 0\nfor (i=0; i<msg.payload.length; i++){\n if (msg.payload[i].type == \"public\") { \n holidays[x] = msg.payload[i].date.substring(0 , 10) \n flow.set([\"holidays\"], [holidays]) \n x=x+1\n }\n}\n\n//change format to dd-mm-yyyy\nfor (i=0; i<holidays.length; i++){\n holidays[i] = holidays[i].substring(8 , 10) + '-' + holidays[i].substring(5 , 7)+ '-' + holidays[i].substring(0 , 4)\n flow.set([\"holidays\"], [holidays]) \n}\n\nmsg.topic = \"Holidays\"\nmsg.payload = holidays\nnode.warn(holidays)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":180,"wires":[[]]},{"id":"c900d44f65722543","type":"http request","z":"20bb0f7f9fab47a8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":350,"y":180,"wires":[["de7faf407b15924b"]]},{"id":"b4c1115243f267a4","type":"inject","z":"20bb0f7f9fab47a8","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":100,"wires":[["828ebac7791878b5"]]},{"id":"828ebac7791878b5","type":"function","z":"20bb0f7f9fab47a8","name":"Next day URL","func":"var nowMS = Date.now();\nvar nowDate = new Date(nowMS);\nvar thisyear = nowDate.getFullYear() \nvar holidays = flow.get([\"holidays\"]) || [];\nnode.warn(holidays)\n\n\nh1 = \"https://api.generadordni.es/v2/holidays/holidays?country=ES&year=\"\nmsg.url = h1 + thisyear \n\n// check if holiday array is already created\nif (holidays.length>2){\n msg.payload = true\n} else {\n msg.payload = true\n} \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":100,"wires":[["c900d44f65722543"]]}]