Passing from and to date and time to http request node

Hello!
Need help!

I am trying to read value of current date and time to pass it to http request node.
Please help me with this.

[{"id":"ab460fa4.e776e","type":"ui_button","z":"24076265.de751e","name":"","group":"6b69c47b.954aec","order":0,"width":0,"singleBrowser":false,"height":0,"passthru":false,"label":"This MonthHttp","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","powerMode":false,"x":80,"y":680,"wires":[["7d8310a6.c23ae"]]},{"id":"f41c2db2.f9b7f","type":"change","z":"24076265.de751e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":620,"wires":[["5442bc40.8b1334"]]},{"id":"5442bc40.8b1334","type":"function","z":"24076265.de751e","name":"","func":"const date = new Date();\n\nlet day = date.getDate();\nlet dayone = 1;\n//let yesterday = date.getDate() -1 ;\nlet month = date.getMonth() + 1;\nlet year = date.getFullYear();\n\nlet yesterDate = `${year}-${month}-${dayone} 00:00:01`;\nlet currentDate = `${year}-${month}-${day} 23:00:59`;\n//let yesterDate = `2022-11-01 00:00:01`;\n//let currentDate = `2022-11-01 23:00:59`;\nmsg.from=new Date(yesterDate).toISOString();\nmsg.to=new Date(currentDate).toISOString();\nreturn msg;\n\n\n\n\n\n","outputs":"1","language":"javascript","noerr":0,"x":460,"y":620,"wires":[[]],"outputLabels":["From"]},{"id":"53d4fc8.35f1404","type":"debug","z":"24076265.de751e","name":"","active":true,"console":"false","xaxis":"_time","complete":"false","x":610,"y":740,"wires":[]},{"id":"7d8310a6.c23ae","type":"http request","z":"24076265.de751e","name":"","method":"GET","ret":"obj","url":"","timeout":"","mindspherePath":"/api/iottsaggregates/v4/aggregates?assetId=ded1a0bfec43400f970e566f8263c6d3&aspectName=BatchMix&from=2022-12-01T00:00:00.000Z&to=2022-12-29T00:00:00.000Z&intervalUnit=hour&intervalValue=12&select=Agg1_Total_Weight","useMindsphereAuth":true,"isAdmin":false,"secretHeaders":"","x":630,"y":680,"wires":[["53d4fc8.35f1404","16010add.809725","a867b120.a6e2e"]]},{"id":"6b69c47b.954aec","type":"ui_group","z":"","name":"OneMonth","tab":"7ecbab01.42a594","order":1,"disp":true,"width":"20","collapse":false,"_type":"config"},{"id":"7ecbab01.42a594","type":"ui_tab","z":"","name":"DATA","icon":"dashboard","publicAccess":"true","fmAccess":"none","fmAccessType":"private","assetType":"","asset":"","assetName":"","assetText":"","image":"","description":"","hideTitleBar":false,"_type":"config"}]

The flow you show does not appear to be attempting to pass the current date/time to a request node.

I suggest you get an example of what you want running using an inject node to inject the date/time then post that then we will understand better what you are trying to achieve.

[Edit] I see that the title of the thread and the description in the first post appear to be in disagreement as to what you want, so even more reason to post a working example.

You can pass the url to the http node using msg.url. So in your function, once you have your dates you can construct the url.
e.g

msg.url = `http://example.com?from=${msg.from}&to=${msg.to}` 

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