Redirect using custom PHP action

Wondering if there’s any way I can parse this JSON return?

The form submission is working fine, but that is it. It does nothing after a successful submission.

document.addEventListener('bricks/form/success', function(event) {
  console.log('Form submission success event:', event);
});

is returning nothing for me… am I missing something?

Looks like you are using bricksforge form? If so, i’ll suggest you post in their forum

I am, but it hooks into the original bricks/form/success event according to their docs? They forward you directly to Form Element – Bricks Academy which states it in their docs.

Well, if anyone stumbles upon the same issue here’s my solution:

(function (originalFetch) {
  window.fetch = function (...args) {
    const url = args[0];

    if (url.includes('/wp-json/bricksforge/v1/form_submit')) {
      console.log('Bricksforge form submit detected via fetch');
    }

    return originalFetch.apply(this, args).then(response => 
      response.json().then(json => {
        const { results } = json;
        
        if (results && results.success) {
          results.success.forEach(({ action, type, finance_link }) => {
            if (action === 'send_finance_lead' && type === 'success') {
              console.log('Redirecting to finance link in 3 seconds...');

              if (finance_link) {
                setTimeout(() => {
                  console.log('Opening finance link:', finance_link);
                  window.open(finance_link, '_blank');
                }, 3000);
              }
            }
          });
        }

        return response; // Ensure the response is returned
      })
    );
  };
})(window.fetch);