Problem with Body-Parser

Asked

Viewed 29 times

0

I have a problem with Runtime of Javascriptthe NodeJs, I finished the modules bodyParser, express and handlebars

Yet I can’t bring myself to parameter req, exactly the req.body.name and the following error appears to me:

Error: TypeError: Cannot read property 'descricao' of undefined

Nodejs:

    app.post("/validar", function(req,res){
        
        req.body.descricao
        res.send("A descrição foi"+req.body.descricao )
        

    })

Handlebars:

<form action="/validar" method="POST">
    <p>Produto: </p>
    <input type="text" name="produto">
    <p>Descrição: </p>
    <textarea name="descricao"></textarea>
    <button type="submit">Cadastrar postagem</button>
</form>


  • 1

    body-parser cannot handle Multipart requests, I believe that answers your question https://stackoverflow.com/questions/37630419/how-to-handle-formdata-express-4 Just one remark, Nodejs is not a language in itself, it is a javascript Runtime that allows you to run javascript server-side code

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.