John Mike
John Mike6mo ago

[Solved] Frontend script call backend script, do UI stuff and download the returned data as file

Hello everyone, new windmill user here. Trying to grasp how windmill works and building a small internal app at the same time. I'm trying to wrap my head how I can have my own frontend script run a backend script, get the result, do some UI stuff based on the result and download it on the user's computer (through the normal browser's download dialog). I see that a backend inline script "just works" without any additional action from me. But what about when I need to run that backend script from a frontend script and do something with the results (including downloading it)? Is a Transformer the right solution? Or maybe the web Fetch API (run a fetch request from the frontend script to my windmill API, trigger the backend script and get the result). For now, I have stored my backend script on the workspace scripts and linked the button with it. Then added a Transformer with the usual javascript code for downloading files (found in the docs and windmill ai). Thanks!
2 Replies
rubenf
rubenf6mo ago
Transformer is very likely the right solution frontend script calling backend scripts make assumptions about permission that fall outside of the app policy and depend only on the viewer's permission
John Mike
John Mike6mo ago
Thank you very much for verifying it and providing additional details.