Thursday, 16 March 2017

In Hapijs: TypeError: Cannot read property 'uri' of undefined

I am new in hapijs. And i am creating a demo app. But when I am using command node demo.js then got this error. Please make sure me where I am doing mistake in this code:

'use strict'
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 3010, host: 'localhost' });


server.route({
    method:'GET',
    path:'/{name}',
    handler:function(request,reply) {
        reply('Hello , '+encodeURIComponent(request.params.name)+' !');
    }
});

    server.start((err) => {
    if (err) {
        throw err;
    }
    console.log(`Server running at: ${Hapi.info.uri}`);
});



via Surya

No comments:

Post a Comment