Okay, here ya go.
In a nutshell, I open a modal on the front end that triggers a server action that performs the api call to create the pdf. The modal shows a “your report is being prepared” message during creation, and then displays a link the pdf once finished.
Use your own Authorization key in the header.
JSON Data (my specific data removed to simplify):
"fileName": "Report filename",
Make sure you use the Define API Schema option when building your server action, so the results of the api are exposed to the front end.
Front end Modal:
The server connect is triggered to load when the modal opens (User clicks “Download report” button and the modal opens to start the process.) The link element is hidden while the server connect is executing, and dynamically sets the link value based on the results of the server connect:
I use a border spinner to let the user know something is happening during the server connect execution: