I have a project structure looks like this.
src/core/sample1.js
class MyPro1 {
constructor() {
}
print_data() {
return 'Prine';
}
smaple_data() {
console.log(this.print_data());
return 'this';
}
}
module.exports = MyPro1;
src/externals/polis.js
const MyPro1 = require('../core/sample1');
const MyPro = require('../utils/usable');
class MyRock {
constructor() {
this.content = new MyPro1();
}
call_methods() {
let data = MyPro.smaple_data('100', this.content.smaple_data, null);
console.log(data);
}
}
const x = new MyRock();
x.call_methods();
src/utis/usable.js
class MyPro {
static smaple_data(data, method, call) {
method();
return data;
}
}
module.exports = MyPro;
I am calling utils and core js files inside it. It throws error but don't know how to solve this error.
Traceback
console.log(this.print_data());
TypeError: Cannot read property 'print_data' of undefined