Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Last active March 15, 2018 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzkmx/d88c29f5adeda56cefef96565c197370 to your computer and use it in GitHub Desktop.
Save tzkmx/d88c29f5adeda56cefef96565c197370 to your computer and use it in GitHub Desktop.
WP REST API Setup
(function($){
const {root, versionString, nonce} = wpApiSettings
$.ajaxSetup({headers:{"X-WP-Nonce":nonce}})
$.get(`${root}${versionString}users/me`)
.then(userData => {
console.log(userData)
}, error => {
console.warn(error)
})
/* Example customization of user description */
$.post(`${root}${versionString}users/me`, {
meta: {
"wpseo_title": "Rocking with the REST API"
}
})
.then(userData => {
console.log(userData)
}, error => {
console.warn(error)
})
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment