为什么不自动解析有效负载?
Why payload is not parsed automatically?
hapijs 17.2.0
路线是
{
method: 'POST',
path: '/node/create',
handler: function(request, h) {
console.log(request.payload);
},
}
Post我的数据
curl -d '{"path": "dinos.456", "node": {"name": "velociraptor", "speed": 50, "force": 20}}' -X POST http://localhost:7001/node/create
我在服务器上看到了这个结果
{ '{"path": "dinos.456", "node": {"name": "velociraptor", "speed": 50, "force": 20}}': '' }
为什么没有像在 hapi v16 中那样自动将有效负载解析为对象?也许我错过了路线中的一些新选项?
如果没有设置
{
method: 'POST',
config: {
validate: {
payload: { /* joi schema */ }
}
}
}
然后有效负载将是行缓冲区有效负载,
需要自己格式化
hapijs 17.2.0
路线是
{
method: 'POST',
path: '/node/create',
handler: function(request, h) {
console.log(request.payload);
},
}
Post我的数据
curl -d '{"path": "dinos.456", "node": {"name": "velociraptor", "speed": 50, "force": 20}}' -X POST http://localhost:7001/node/create
我在服务器上看到了这个结果
{ '{"path": "dinos.456", "node": {"name": "velociraptor", "speed": 50, "force": 20}}': '' }
为什么没有像在 hapi v16 中那样自动将有效负载解析为对象?也许我错过了路线中的一些新选项?
如果没有设置
{
method: 'POST',
config: {
validate: {
payload: { /* joi schema */ }
}
}
}
然后有效负载将是行缓冲区有效负载, 需要自己格式化