I'm trying to submit a form and save the data in database but I can't receive the data.
My route is that:
routes.post('/new-inventory/:dbname', inventory.store);
My function in controller is that: I just do a console log to see if I receive the data. I know that is go to this function because show the first console.log . The req.body
return {}
.
store: (req, res) => {
console.log('Storing new inventory...');
console.log(req.body)
},
My form in html (jade) is that:
div(class="popup-content")
form(action="/new-inventory/#{dbname}" method="post")
div(class="popup-title")
span Novo inventário
div(class="popup-data")
div(class="form-group")
label(for="inventory-description") Descrição
input(type="text" id="inventory-description" value="#{description}" class="form-control" disabled)
div(class="form-group")
label Armazém
select(class="form-control" id="wharehouse-select")
each whare, i in wharehouse
option(value="#{whare.szzstamp}" data-option="#{whare.armazem}") #{whare.armazem} - #{whare.zona}
div(class="form-group")
label(for="inventory-date") Data
input(type="text" id="inventory-date" class="form-control")
div(class="popup-button")
div(class="btn-submit")
button(type="submit") Criar
div(class="close-btn")
span Cancelar
In my node serve I start body-parser
:
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // get information from html forms
How can I do this? What I'm doing wrong?
Thank you
只需在每个输入标签中添加name
属性
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.