Is it possible to then draw out that colour or type value to then use it in other functions?
Copying the path for the type of the first bin gives payload.collectionWeeks[0].bins[0].type, which I'm guessing identifies where it sits in the resultant array. However it gives an error when using this path when trying to essentially say:
new variable = payload.collectionWeeks[0].bins[0].type
If new variable = food then new variable = blue
The end goal is that I want to be able to post the colour to a webpage to be able to view by other devices.
[{"id":"27f0628ce2b73c52","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"38b3fec2fa415e98","type":"debug","z":"27f0628ce2b73c52","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":260,"wires":[]},{"id":"b07ee27e4184ed20","type":"function","z":"27f0628ce2b73c52","name":"add bin Colors","func":"let weeks = msg.payload.collectionWeeks;\n\n\nweeks.forEach(week => {\n week.bins.forEach(bin => {\n if (bin.type === \"General\") { bin.colour = \"white\" }\n if (bin.type === \"Food\") { bin.colour = \"blue\" }\n if (bin.type === \"Garden\") { bin.colour = \"green\" }\n })\n});\n\nmsg.payload = weeks;\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":320,"wires":[["38b3fec2fa415e98","8a3373dc55e9a981"]]},{"id":"1c44140cb8acf2cb","type":"inject","z":"27f0628ce2b73c52","name":"","props":[{"p":"payload"}],"repeat":"72000","crontab":"","once":true,"onceDelay":0.1,"topic":"","payloadType":"date","x":170,"y":120,"wires":[["6da13aa2886382d1"]]},{"id":"b7762aa66de6a566","type":"http request","z":"27f0628ce2b73c52","name":"auth req","method":"POST","ret":"txt","paytoqs":"body","url":"https://authwebservice.cardiff.gov.uk/AuthenticationWebService.asmx?op=GetJW","tls":"","persist":true,"proxy":"","authType":"","x":400,"y":180,"wires":[["682b5c419c834422"]]},{"id":"6da13aa2886382d1","type":"function","z":"27f0628ce2b73c52","name":"","func":"msg.headers = {\n \"Content-Length\": \"284\",\n \"Accept-Encoding\": \"gzip, deflate, br\",\n \"Referer\": \"https://www.cardiff.gov.uk/\",\n \"Origin\": \"https://www.cardiff.gov.uk\",\n \"Content-Type\": `text/xml; charset=\"utf-8\"`,\n \"Sec-Fetch-Dest\": \"empty\",\n \"Sec-Fetch-Mode\": \"no-cors\",\n \"Sec-Fetch-Site\": \"same-site\",\n \"Pragma\": \"no-cache\",\n \"Cache-Control\": \"no-cache\"\n}\n\nmsg.payload = `<?xml version='1.0' encoding='utf-8'?><soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'><soap:Body><GetJWT xmlns='http://tempuri.org/' /></soap:Body></soap:Envelope>`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":180,"wires":[["b7762aa66de6a566"]]},{"id":"682b5c419c834422","type":"xml","z":"27f0628ce2b73c52","name":"","property":"payload","attr":"","chr":"","x":530,"y":180,"wires":[["24b162b725bfb0a2"]]},{"id":"24b162b725bfb0a2","type":"function","z":"27f0628ce2b73c52","name":"","func":"let access_token = JSON.parse(msg.payload[\"soap:Envelope\"][\"soap:Body\"][0].GetJWTResponse[0].GetJWTResult).access_token\n\nmsg.payload = {\n \"systemReference\": \"web\",\n \"language\": \"eng\",\n \"uprn\": 10094241834 // code for address ?? you need to find it from browser\n}\n\nmsg.headers = {\n \"Authorization\": `Bearer ${access_token}`\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":260,"y":260,"wires":[["b091cd6df0893112"]]},{"id":"b091cd6df0893112","type":"http request","z":"27f0628ce2b73c52","name":"WasteCollection req","method":"POST","ret":"obj","paytoqs":"body","url":"https://api.cardiff.gov.uk/WasteManagement/api/WasteCollection","tls":"","persist":false,"proxy":"","authType":"","x":440,"y":260,"wires":[["b07ee27e4184ed20","2c5279c597838494"]]},{"id":"2c5279c597838494","type":"debug","z":"27f0628ce2b73c52","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":920,"y":140,"wires":[]},{"id":"8a3373dc55e9a981","type":"function","z":"27f0628ce2b73c52","name":"SaveToGlobal","func":"global.set('bincolour',msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":960,"y":400,"wires":[[]]},{"id":"8980c46f8934c893","type":"http in","z":"27f0628ce2b73c52","name":"mybin","url":"/mybin","method":"get","upload":false,"swaggerDoc":"","x":160,"y":440,"wires":[["2ff426b235e5a3f3"]]},{"id":"2ff426b235e5a3f3","type":"function","z":"27f0628ce2b73c52","name":"getFromGlobal","func":"var newMsg = RED.util.clonemessage(msg);\nnewMsg.payload = JSON.stringify(global.get('bincolour')).replace(/\\\"/g\", \"\");\nreturn msg;","outputs":1,"noerr":6,"initialize":"","finalize":"","libs":[],"x":370,"y":440,"wires":[["6fec5ac8175e8819"]]},{"id":"6fec5ac8175e8819","type":"template","z":"27f0628ce2b73c52","name":"DisplayOnPage","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}","output":"str","x":590,"y":440,"wires":[["5e9586894bbb69e5"]]},{"id":"5e9586894bbb69e5","type":"http response","z":"27f0628ce2b73c52","name":"success","statusCode":"200","headers":{},"x":830,"y":480,"wires":[]}]
This is where I'm at, I just need to be able to take that colour variable and then post to that page.
Any thoughts?