Skip to content

Instantly share code, notes, and snippets.

@andyfleming
Created November 17, 2016 12:58
Show Gist options
  • Save andyfleming/d38e0968e1fea1417e1ec61207bf087e to your computer and use it in GitHub Desktop.
Save andyfleming/d38e0968e1fea1417e1ec61207bf087e to your computer and use it in GitHub Desktop.
Example front-end User API Call
jQuery.ajax({
url: '/-api/user/profile',
xhrFields: {
withCredentials: true
},
success: function(data, textStatus, jqXHR) {
console.log(data.data.first_name)
},
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 401) {
console.log('user is not logged in')
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment