Skip to content

submitError

submitError is a DOM event that occurs whenever the form based on a form-connector webcomponent throws an error during submitting.

Event body

The submitError body has a TFormConnectorSubmitErrorEventDetail type which represents the details of the thrown error during a submit. It is optional so it might not exist.

Example

In this example we listen to submitError event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    document.addEventListener('submitError', (event) => {
        const detail = event.detail;

        if (!detail) return;

        const { form, submitActionProps } = detail;

        console.log(form, 'has thrown an error during submission with following props:', submitActionProps);
    });
});