What Ive tried is this
function checkServer(url, timeout) {
const controller = new AbortController();
const signal = controller.signal;
const options = { mode: 'no-cors', signal };
return fetch(url, options)
.then(setTimeout(() => { controller.abort() }, timeout))
.then(response => console.log('Check server response:', response.statusText))
.catch(error => console.error('Check server error:', error.message));
}
var check = checkServer("https://www.youtube.com/xxxxxxxxxxx", 2000)
But the programm I am using doesnt work with it it says:
Error: empty expression not allowed (line 6)
Edit: This is not for a website so I cant use html but I can use a server with a php file if thats any help to making this work