How to obtain a promise when use dmx.parse in javascript

Hi, I want to obtain a response when I send in javascript this:

dmx.parse('content.form1.submit()');

How to obtain a promise when I submit a form by javascript, for example I want to get the “state” and “status” from “content.form1” while is executing, for example, get the state.executing to execute another function, or get the status to execute another function after full load of the submit form.

Thanks

           dmx.parse('content.form1.submit()');

            await new Promise(resolve => {
                const checkExecuting = () => {
                    const executing = dmx.app.data.content.form1.state.executing;

                    if (!executing) {
                        resolve();
                    } else {
                        setTimeout(checkExecuting, 200);
                    }
                };
                checkExecuting();
            });

            const status = dmx.app.data.content.form1.status;

            if (status === 200) {
                return "¡Formulario completado con éxito!";
            } else {
              console.error("Error");
            }

Well, this works for me now, I don’t know if it’s the best option.

2 Likes

It’s the way I would do too, maybe with a shorter interval like 10ms

1 Like

Thanks @Apple