function checkCookies(host) { fetch(host + '/same-site-cookies', { mode: 'cors', credentials: 'include' }) .then(response => { if (response.ok) { return response.json(); } else { alert('Error in response'); return; } }) .then(data => { if (typeof data === 'object') { const received = Object.keys(data).filter(key => data[key]); alert('Cookies received:\r\n\r\n' + received.join('\r\n')); } else { alert('No cookies received'); } }); }