I'm trying to use a class from A.js file in B.js file, i made an instance of A.js class and tried to call its function in B.js, but i got an error saying
Uncaught SyntaxError: Cannot use import statement outside a module
this is what the code looks like:
A.js file
export class A {
constructor() {
this.name = 'A'
}
getName() {
return this.name;
}
}
B.js file
import A from './A.js';
const a = new A();
console.log(a.getName());
what am i doing wrong?