Reputation: 5644
hapijs 17.2.0
The route is
{
method: 'POST',
path: '/node/create',
handler: function(request, h) {
console.log(request.payload);
},
}
Post my data
curl -d '{"path": "dinos.456", "node": {"name": "velociraptor", "speed": 50, "force": 20}}' -X POST http://localhost:7001/node/create
And I see this result on the server
{ '{"path": "dinos.456", "node": {"name": "velociraptor", "speed": 50, "force": 20}}': '' }
Why is the payload not parsed into object automatically like it was in hapi v16? Maybe I miss some new option in the route?
Upvotes: 0
Views: 357
Reputation: 61
if not set
{
method: 'POST',
config: {
validate: {
payload: { /* joi schema */ }
}
}
}
then the payload will be a row buffer payload, you need to format it by yourself
Upvotes: 1