Skip to content

Instantly share code, notes, and snippets.

@mindmergedesign
Forked from alikrc/ajaxBearer.js
Created November 1, 2017 21:27
Show Gist options
  • Save mindmergedesign/e0f4517d2e2cf6ed7d3478cb87a9f4d7 to your computer and use it in GitHub Desktop.
Save mindmergedesign/e0f4517d2e2cf6ed7d3478cb87a9f4d7 to your computer and use it in GitHub Desktop.
ajax post with bearer token
$.ajax({
url: "http://localhost:33460/api/Account/userinfo",
dataType: 'json',
data: {
foo: 'bar'
},
success: function(data, status) {
return console.log("The returned data", data);
},
beforeSend: function(xhr, settings) { xhr.setRequestHeader('Authorization','Bearer ' + tokenString ); } //set tokenString before send
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment