Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
* Import remote dependencies.
*/
import Axios from 'axios';
/*
* Create a Api object with Axios and
* configure it for the WordPRess Rest Api.
*
* The 'mynamespace' object is injected into the page
* using the WordPress wp_localize_script function.
*/
const Api = Axios.create({
baseURL: mynamespace.rootapiurl,
headers: {
'content-type': 'application/json',
'X-WP-Nonce': mynamespace.nonce
}
});
export default Api;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.