I have two files a.js and b.js. The first one runs an async function, which contains a variable that changes everytime something is modified. I want to access the same variable with the modified data in it on another .js file
// a.js
var nodes; // I have defined a global variable
async function createEditor(container) {
...
async function compile() {
await engine.abort();
await engine.process(editor.toJSON());
nodes = engine.process(editor.toJSON());
}
}
export {nodes};
The second .js file contains: -
// b.js
import {nodes} from './a.js';
console.log(nodes) // Outputs Undefined