I'm implementing some features on a form that require interaction with a web service. I have some challenges with implementation.
I have added a script to the <head> of the form that generates a unique session ID, and dynamically adds a <script> tag to the <head>. The script runs on page load and inserts the script tag. The script in the tag runs as expected.
The second action is to make an API call to a web service using some of the data generated for the first script. This needs to happen without user input. The result of the web service call is used to determine the form page flow.
I need to include some private data in the request (api_key) so I can't put that directly in the form. How can I include private data?
I have considered the following options, but can't seem to get one that works.
Are there any other ways to call a web service from a Composer form?
Any ideas would be appreciated.
Another option is to use a prefill service to push some data to the form (session ID and api_key).
However, I can't work out how to push data to the <head> of the form, I can only push data to form fields. That won't work as the script needs to run during page load, but this would fail as the fields would not be defined when the script runs.