Wednesday 27 March 2019

Problem to save a form with select populate by database.

Hi, i have this on controller:const novaForm = async ({ Maquina }, req, res) => {const docs = await Maquina.find({status: 'livre'})res.render('operacoes/nova', { docs })}​this on view:​Controller to save:const novaProcess = async ({ Operacao }, req, res) => {const operacao = new Operacao(req.body)try{await operacao.save()res.redirect('/operacoes')} catch (e) {res.render('operacoes/nova', {errors: Object.keys(e.errors)})}}​And thats works correctly, the problem is when i try to save this on new table (operacao) on mongo, thats return this error:>> 47| <% docs.forEach( maq => { %>docs is not defined​Somebody have some clue? Ty..

Submitted March 27, 2019 at 06:08PM by azkrad

No comments:

Post a Comment