window.subscribe = async function (e) { e = e || window.event; e.preventDefault(); try { let email = e.srcElement[0].value; let res = await $.post('/api/contacts', { email }); $('.subscribe_letter').hide(); $('.thank_subscribe').show(); if (res && res.challenge) { sessionStorage.setItem('challenge', JSON.stringify(res)); window.location.href = '/challenge'; } else { window.snaptr && window.snaptr('track', 'SUBSCRIBE'); } } catch (error) { return false; } }