Dynamic scripting using external variables is already possible using hidden fields in scripts, the drawback of this approach is that these external variables are included in the form payload (with the risk to expose sensitive data)l
Solution
Create a form context to be used for custom read-only variables storage inside form and scripts
<LetsForm
form={MY_FORM}
defaultValues={myDefaultValues}
// ...
context={{
myVar: 42,
myToken: 'abc'
}}
/>
then in the Form Schema
{
// ...
fields: [
// ...
{
component: 'input-text',
name: 'my_field',
label: 'My Field',
script: `const token = context('myToken');
const res = await fetch('https://...', {
headers: {
'Authorization': 'Bearer ' + token
}
});
`
}
]
}