Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active April 15, 2024 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vanaf1979/7f1db9d7f67d49a339f56d65222b941b to your computer and use it in GitHub Desktop.
Save vanaf1979/7f1db9d7f67d49a339f56d65222b941b to your computer and use it in GitHub Desktop.
/*
* 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