0
我有一个玉模板,我有一个创建用户部分,将用户添加到orchestrate.io数据库。在此之下,我列出了所有拥有删除和更新链接的用户。删除工作正常通过传递密钥通过URL作为res.params.id当它到达服务器。当我使用密钥更新时,它看不到来自输入字段的新值,所以我没有得到在服务器端使用的有效负载值。我怎样才能更新这个领域?这里是我的代码: 服务器端 -更新玉输入到hapi.js
server.route({
method: 'GET',
path: '/update/{id}',
handler: function(req, reply){
db.put('users', req.params.id, {
"name": 'name',
"password": 'password',
"email": 'email'
})
.then(function (result) {
reply.redirect('/');
})
.fail(function (err) {
reply('no update');
});
}
});
玉模板 -
doctype html
html
head
title Last October Weekly Challenge
body
div.container
p This is the main user page. You can create, update, delete and view users.
form(action='/',method='POST')
label(for='name') Name
input(id='name',type='text',value='',placeholder='Enter Name',name='name')
label(for='password') Password
input(id='password',type='password',value='',placeholder='Enter Password',name='password')
label(for='email') Email
input(id='email',type='email',value='',placeholder='Enter Email',name='email')
input(id='submit',type='submit',value='Create User',name='submit')
p Here are the current users:
table
each item in items
tr
td
input(type='text' name='update-name' value= item.value.name)
td
input(type='text' name='update-password' value= item.value.password)
td
input(type='email' name='update-email' value= item.value.email)
td
a(href="/delete/" + item.path.key) Delete
td
a(href="/update/" + item.path.key) Update
谢谢你的帮助。