I am trying yo create a constructor from another file to my project, the thing is, when y run my js only recognice the constructor if is declared in the same file, like this... This Works
function docWeb(){
this.index = fs.readFileSync('./shalimar/index.html');
this.userLogin = fs.readFileSync('./shalimar/home-shalimar-user.html');
this.galery = fs.readFileSync('./shalimar/galeria.html');
this.basket = fs.readFileSync('./shalimar/carrito.html');
this.sells = fs.readFileSync('./shalimar/facturacion.html');
this.upload = fs.readFileSync('./shalimar/upload.html');
}
var pagina = new docWeb();
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write(pagina.userLogin);
res.end();
return;
/*This Works*/
But when i try to take the constructor to another file
var mod= require('./modulos/mod1');
var pagina = new mod.docWeb();
res.writeHead(200, { 'Content-Type': 'text/html' });
res.write(pagina.userLogin);
res.end();
return;
/*mod1*/
var fs = require('fs');
exports.docWeb = () =>{
this.index = fs.readFileSync('./shalimar/index.html');
this.userLogin = fs.readFileSync('./shalimar/home-shalimar-user.html');
this.galery = fs.readFileSync('./shalimar/galeria.html');
this.basket = fs.readFileSync('./shalimar/carrito.html');
this.sells = fs.readFileSync('./shalimar/facturacion.html');
this.upload = fs.readFileSync('./shalimar/upload.html');
}
This throw me
TypeError: mod.docWeb is not a constructor