I have a class
class advertHandler {
constructor(projects) {
this.projects = projects;
}
getProject(name) {
return this.projects[name];
}
}
module.exports = new advertHandler(projects);
When I try to use it like this
const advertHandler = require('./advertHandler')(projectsArray);
advertHandler.getProject('test');
And it throws an exception, require is not a function
, but without a constructor, everything is fine, so the question is how to use the class constructor with require?