양식을 제출하고 데이터베이스에 데이터를 저장하려고하는데 데이터를받을 수 없습니다. 컨트롤러Express - POST 양식에서 데이터를 가져 오는 방법
routes.post('/new-inventory/:dbname', inventory.store);
내 기능입니다 :
내 경로는 점이다 난 그냥 데이터를 수신 있는지 확인하기 위해 콘솔 로그를 않습니다. 첫 번째 console.log를 보여주기 때문에이 함수로 간다. req.body
은 {}
입니다. 내 노드에서
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
내가 body-parser
을 시작으로 게재 :
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true })); // get information from html forms
나는이 어떻게 할 수있는
store: (req, res) => {
console.log('Storing new inventory...');
console.log(req.body)
},
HTML (옥) 나의 양식은 무엇입니까? 내가 뭘 잘못하고있어?
는
당신이 그것을 작동 입력 – Tien
를 사용하여 이름 ATTR에 대한'name' 속성을 추가하지만 이름을 추가하면하지 않았다고 생각 비활성화 된 첫 번째 입력을 제외하고 그 해결책은 무엇입니까? @Tlen – agit