Created
November 17, 2016 12:58
-
-
Save andyfleming/d38e0968e1fea1417e1ec61207bf087e to your computer and use it in GitHub Desktop.
Example front-end User API Call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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