Hi all,
I have a form that collects text from 2 text inputs. From there i need to collect the inputs and then run 2 http calls, one for a token the other for the response needed.
When i get a response i either need to continue or display the error message back into the form so the user can try again.
Is it possible to listen to the click events in a form? The flow http fucntion is very basic and doesnt allow for the repsonse to be used with actions and logic.
Below is an example of what I need.
/**
* Handler that will be called during the execution of a PostLogin flow.
*
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
*/
exports.onExecutePostLogin = async (event, api) => {
api.prompt.render(event.secrets.FORM_ID);
const input1 = event.prompt.fields.input1
const input2 = event.prompt.fields.input1
const button = event.prompt.id = 'button1'
button.onclick () => {
// GET A TOKEN
const getToken = await fetch(url)
const token = getToken.response()
// GET THE DATA
const getData = await fetch(url, token)
const data = getData.response()
if(data.err){
api.prompt.render(':form_id', {
vars: {
errmsg: '123',
}
});
} else {
return;
}
}
};