How to use an ui-button with a http in node

I want to export a file by clicking a button. There are the flows I'm using for:

[{"id":"7adc8e2c.3a56d","type":"function","z":"339f2e0a.80f992","name":"Base path","func":"//var basePath = \"/home/pi/Documents/S0_data/\";\nvar basePath = \"/var/snap/node-red/675/\";\nvar filename = msg.req.params.fn;\n\n\nif(filename.includes(\"..\\\\\")){\n    msg.payload = \"Illegal file path\";\n    msg.statusCode = 405;//not allowed\n    return [null, msg];//fire output 2\n} else if(filename.includes(\"../\")){\n    msg.payload = \"Illegal file path\";\n    msg.statusCode = 405;//not allowed\n    return [null, msg];//fire output 2\n} \n//TODO: add more checks\n\nmsg.filename = basePath + filename;\nreturn [msg, null];//fire output 1\n\n\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":240,"y":140,"wires":[["a1d36f5f.bfd8d"],["74bf307e.adb05"]]},{"id":"74bf307e.adb05","type":"http response","z":"339f2e0a.80f992","name":"","statusCode":"","headers":{},"x":410,"y":200,"wires":[]},{"id":"a1d36f5f.bfd8d","type":"file in","z":"339f2e0a.80f992","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","x":410,"y":140,"wires":[["74bf307e.adb05"]]},{"id":"ea09d67e.e1bda8","type":"catch","z":"339f2e0a.80f992","name":"","scope":null,"uncaught":false,"x":100,"y":200,"wires":[["68386e48.5dacf"]]},{"id":"68386e48.5dacf","type":"function","z":"339f2e0a.80f992","name":"Set 404","func":"msg.payload = msg.error;\nmsg.statusCode = 404;//resource not found\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":200,"wires":[["74bf307e.adb05"]]},{"id":"3c05ab7d.2c9ed4","type":"ui_template","z":"339f2e0a.80f992","group":"2b825e99.b695e2","name":"Download Button","order":9,"width":"2","height":"1","format":"<button style= \"background-color:#097479; border-color:#097479; color:white; font-size: 13px; padding: 10px\" button onclick=\"document.location='/var/snap/node-red/675/export.csv'\"><b>Download</b></button>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":130,"y":80,"wires":[[]]},{"id":"46bab025.c8036","type":"http in","z":"339f2e0a.80f992","name":"[Get] path","url":"/var/snap/node-red/675/:fn","method":"get","upload":false,"swaggerDoc":"","x":100,"y":140,"wires":[["7adc8e2c.3a56d"]]},{"id":"2b825e99.b695e2","type":"ui_group","name":"Buttons","tab":"20a844b0.75e7fc","order":8,"disp":false,"width":"5","collapse":false},{"id":"20a844b0.75e7fc","type":"ui_tab","name":"S314","icon":"fa-2x fa-bar-chart","order":3,"disabled":false,"hidden":false}]

The code is working fine but I want to use an ui-button instead the template button, is it possible?
Thanks in advance.

No, it is not possible. The ui button is for the Dashboard which is a separate set of features.

I suspect the OP wants to use a ui-button node (on their dashboard) in place of a ui-template with a button in - to initiate (on click) a call to the endpoint to download a document.

@between The answer is Yes, but it is more difficult. The ui-button is intended to call back to server side (to node-red) where as the onclick of the button in the ui-template runs client side (which is what you need to initiate a download)

What is wrong with using a template button? You can style it to look identical to the ui-button.

Hi.

There’s nothing wrong using the ui-template button. But what I want to do is to download a csv file previously created from data of a database. With the shared flows I need two separate actions to do the job: one for writing the data to the file and another to download it (by using the ui-template button). I don’t know how to link the first action with an ui-template button to do the second action, neither how to call a http in node from the flow (first action). That’s why I asked to for the use of a ui-button, because I can link the flow with the button’s input.

Regards,

Juan.