Last active
March 15, 2018 19:53
-
-
Save tzkmx/d88c29f5adeda56cefef96565c197370 to your computer and use it in GitHub Desktop.
WP REST API Setup
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
(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