You need to catch the error
fetch('https://www.w3schools.com/nodejs/incorrecturl') .then((response) => { console.log(response.status); }) .catch((error) => { console.error('Request failed:', error); });