The status
property of a
response
contains
HTTP response code:
button.addEventListener('click', function() {
fetch('/ajax.html').then(response => {
console.log(response.status); // e.g. 200
});
});
Print page text if 200
status
code is received, and error if
404
is received.