Ao retornar resp.marko estou obtendo o erro abaixo. Alguém já passou por isso? Poderia auxiliar?
Obrigado.
app.post('/livros', [
check('titulo').isLength({ min: 5 }),
check('preco').isCurrency(),
], function (req, resp) {
const erros = validationResult(req);
if (!erros.isEmpty()) {
console.log("Tá bugado!");
return resp.marko(
require('../views/livros/form/form.marko',
{
livro: {},
errosValidacao: erros.array()
}
)
);
}
console.log(req.body);
const livroDao = new LivroDao(db);
livroDao.adiciona(req.body)
.then(resp.redirect('/livros'))
.catch(erro => console.log(erro));
});
O console.log("Tá bugado!") é exibido no console, mas logo em seguida recebo o erro:
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at write_ (_http_outgoing.js:637:17)
at ServerResponse.write (_http_outgoing.js:629:15)
at BufferedWriter.flush (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\BufferedWriter.js:21:27)
at BufferedWriter.end (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\BufferedWriter.js:30:14)
at AsyncStream._doFinish (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\AsyncStream.js:221:26)
at AsyncStream.end (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\AsyncStream.js:263:22)
at AsyncStream.error (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\AsyncStream.js:446:18)
at Timeout._onTimeout (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\renderable.js:17:22)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at write_ (_http_outgoing.js:637:17)
at ServerResponse.write (_http_outgoing.js:629:15)
at BufferedWriter.flush (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\BufferedWriter.js:21:27)
at BufferedWriter.end (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\BufferedWriter.js:30:14)
at AsyncStream._doFinish (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\AsyncStream.js:221:26)
at AsyncStream.end (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\AsyncStream.js:263:22)
at AsyncStream.error (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\html\AsyncStream.js:446:18)
at Timeout._onTimeout (C:\Users\Rafael\Desktop\Learning\Node\casadocodigo\node_modules\marko\src\runtime\renderable.js:17:22)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)