Get variable to other file

Hey, my code is the following: index.js
import { } from './events/myfile.js'

let result = await fetch('API');
let events = await result.json()

export { events };
import { } from './events/myfile.js'

let result = await fetch('API');
let events = await result.json()

export { events };
myfile.js
import { events } from "./../index.js";

console.log(events);
import { events } from "./../index.js";

console.log(events);
The error I get
ReferenceError: Cannot access 'events' before initialization
ReferenceError: Cannot access 'events' before initialization
What am I doing wrong?
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Schlaumeyer
SchlaumeyerOP2y ago
mhm, you're right... at least I now know what the error is called, thx
Want results from more Discord servers?
Add your server