I’m studing nodejs and ES6 and i tryed to run this code from a module i have writed:
class myDate
{
myDateTime()
{
return Date();
}
myDateTimeAction(req, res){
res.writeHead(200, {'content-Type': 'text/html'});
res.write(`The date and time are currently: ${this.myDateTime()}`);
res.end();
}
}
exports.myDateTimeClass = myDate;
but when i run this code, nodejs prompt: TypeError: this.myDateTime is not a function
What i have to do to make this code run correctly?