我有一个玉模板,我有一个创建用户部分,可以将用户添加到 orchestrate.io 数据库。在其下方,我有一个包含删除和更新链接的所有用户的列表。当它到达服务器时,通过将密钥作为 res.params.id 通过 URL 传递,删除工作正常。当我使用密钥更新时,它看不到输入字段中的新值,因此我没有得到在服务器端使用的有效负载值。如何更新此字段?这是我的代码:服务器端 -
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
感谢您的帮助。