I’m trying to make a personal bookmarklet that presents me the appropriate url depending on web server status. So far, I have ..
javascript:(function() {
function checkServer(url) {
const options = { method: 'HEAD', mode: 'no-cors' };
return fetch(url, options)
.then(response => console.log('Check server response:', response.ok))
.catch(error => console.error('Check server error:', error.message));
}
checkServer('https://www.reddit.com');
})();
I keep getting false
returned for response.ok
in the logs. Is my request being bot filtered by the websites? Or is there something else I’m not understanding? Is there a better approach?