const xhr = new XMLHttpRequest();

xhr.open('GET', 'https://your-backend-domain.com/api/endpoint', true); // true for asynchronous
xhr.withCredentials = true;

xhr.onload = function() {
  if (xhr.status >= 200 && xhr.status < 400) {
    // ... handle the response
  } else {
    // ... handle the error
  }
};

xhr.onerror = function() {
  // ... handle the error
};

xhr.send();