When accessing the route you specify, the files that I have in the public folder are not loaded, only some are loaded and in the nodejs console you send me the following message:
Error: Can't set headers after they are sent. at SendStream.headersAlreadySent (C:\api-rest\node_modules\send\index.js:402:13) at SendStream.send (C:\api-rest\node_modules\send\index.js:625:10) at onstat (C:\api-rest\node_modules\send\index.js:737:10) at FSReqWrap.oncomplete (fs.js:123:15) Error: Can't set headers after they are sent. at SendStream.headersAlreadySent (C:\api-rest\node_modules\send\index.js:402:13)
My code is as follows:
app.get('/', (req, res, err) => {
Noticias.find({}, (e, noticias) => {
noticias.forEach(function (element) {
var myStrin = '' + element.Contenido;
myStrin = myStrin.slice(0, 100);
element.Contenido = myStrin + '...';
}, this);
if (e) {
console.log(e);
} else if (!noticias) {
console.log("Error, el archivo no existe")
} else {
res.render('index', { noticias, title: "ICMA", uno: "select", dos: "", tres: "", cuatro: "", cinco: "" })
}
})
});