Skip to content

Instantly share code, notes, and snippets.

@czwen
Last active May 22, 2020 01:25
Show Gist options
  • Save czwen/5056beffc4d8823e3f35eecfb92a2f61 to your computer and use it in GitHub Desktop.
Save czwen/5056beffc4d8823e3f35eecfb92a2f61 to your computer and use it in GitHub Desktop.
cors_test.js
var xhr = new XMLHttpRequest();
var token = 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjJkNGE1YTliLTUxNzUtNDBlNS1iZTEwLTEzMTQ3OTg1OGFmYyJ9.nY6LTeWDcPdceB6pnMFb16VIKEkYjl52IpVIzDvhVnRPCRRSXmq48wYxTL5znUpJdHP0nUNFJ4vrxHHnOajbEA';
xhr.open('GET', 'http://localhost/yxt/getInfo');
xhr.setRequestHeader("Authorization",'Bearer '+token);
xhr.send(null);
xhr.onload = function(e) {
var xhr = e.target;
console.log(xhr.responseText);
}
// using in console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment