티스토리 뷰

728x90
function requestUtils(method, url, body, f, bearer) {
  const xhr = new XMLHttpRequest();
  xhr.open(method, url, true);
  xhr.withCredentials = true;
  xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

  bearer && xhr.setRequestHeader("Authorization", bearer);

  xhr.onreadystatechange = function () {
    if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
      f(this.response);
    }
  };
  xhr.send(body);
}

https://stackoverflow.com/questions/51506579/sending-authorization-token-bearer-through-javascript

 

Sending Authorization Token Bearer through Javascript

I'm trying to send a Authorization Token Bearer through Javascript to a REST Endpoint, so i doing in this way: $.ajax( { url: 'http://localhost:8080/resourceserver/protected-no-scope', typ...

stackoverflow.com

 

728x90
댓글