I am using Vue.js
but with simply JS
files and not vue
files and I am importing a component into my main app.js
like so:
import autoPosts from './components/autoPosts.js';
It imports it just fine, but I am trying to access these globals. Before people destroy me for using global variables, can you just tell me if this is possible.
const apiRoot = location.origin + '/wp-json/wp/v2/';
const acfApiRoot = location.origin + '/wp-json/acf/v3/';
import autoPosts from './components/autoPosts.js';
It doesn't read apiRoot
or acfApiRoot
within that component whether I include it before or after the variables.
The only way it works is if I declare the variables inside my component file autoPosts.js