I’ve been creating an exam organizer these days and I needed an examiners list on the other file, I created an object and listed all my examiners. However, while importing theese examiners’ object to main logic file, I am getting an error which says that I can not use import statement outside a module. Here is piece of my code,
import { examiners } from 'database.js';
# other things from html...
submitBtn.onclick = () => { let examinerLocal = localStorage.setItem('exorg-examiner', examiners[0]); }
database.js file
let examiners = [
{
name: "Smn",
surname: "Smb",
age: 94
}
]
It might seem as unfinished but I couldn’t use anything else with this list as I couldn’t import that. And because of this, other logic also stopped functioning.
So I’ve tried to do it by moving it into onclick function but the error I got was the same. I did that because I do not know what the module is here. Moreover, I’ve tried this article and changed the database.js file to this:
export default class examiners {
constructor() {
let examiners = [
{
name: "smn",
age: 20
}
]
}
}
But then I got another error: GET http://127.0.0.1:5500/database net::ERR_ABORTED 404 (Not Found)