Wondering if this is possible or I'm doing something wrong?
My use case is to have a central handler for some backend processing when some events in the retool apps occur.
Rather than sweep those changes hourly with a cron job I'd like to run it when it happens, but triggering it from the browser using a run script action with the javascript fetch() command doesn't seem to work.
eg If I run this from the console or a script action it triggers the workflow (I can see it is in the run history) but never receives any data, I'm guessing it may be related to cors but not sure. The response object in each case is always "empty" with a status of zero because the "no-cors" wipes all that out and it won't run without it.
fetch('https://api.retool.com/v1/workflows/xxxxx/startTrigger?workflowApiKey=xxxxx', {
method: 'POST',
mode:'no-cors',
headers: {
'Content-Type': 'text/plain'
},
body: JSON.stringify({
'action': 'test'
})
});
or
fetch('https://api.retool.com/v1/workflows/xxxxx/startTrigger?workflowApiKey=xxxxx', {
method: 'POST',
mode:'no-cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'action': 'test'
})
});
Logs show this when I test it from within the workflow app with a dummy JSON object:
[log] {
value: { action: 'inline' },
data: { action: 'inline' },
metadata: null,
error: undefined
}
And this when I run that javascript:
[log] { value: {}, metadata: null, data: {}, error: undefined }