reqeuest body in hapijs

Solutions on MaxInterview for reqeuest body in hapijs by the best coders in the world

showing results for - "reqeuest body in hapijs"
Lea
28 Oct 2018
1'use strict';
2
3const Hapi = require('hapi');
4
5const server = new Hapi.Server();
6server.connection({
7    host: 'localhost',
8    port: 8000
9});
10
11server.route({
12    method: 'POST',
13    path:'/',
14    handler: function (request, reply) {
15        console.log(request.payload);
16        console.log(request.raw.req.headers);
17        return reply('hello world');
18    },
19    config: {
20        payload: {
21            output: 'data',
22            parse: false
23        }
24    }
25});
26
27server.start((err) => {
28    if (err) throw err;
29    console.log('Server running at:', server.info.uri);
30});