Adding Routes to Hapi js server

server.route({
method: 'GET',
path: '/',
handler: (request, h) => {

return 'Hello World!';
}
});
'use strict';const Hapi = require('@hapi/hapi');const init = async () => {        const server = Hapi.server({
port: 8000,
host: 'localhost'
});
server.route({
method: 'GET',
path: '/',
handler: (request, h) => {
return 'Hello World!';
}
});
await server.start();
console.log('Server running on %s', server.info.uri);
};});init();
node index.js
Server running at: http://localhost:8000

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aishadeshmukh

aishadeshmukh

Software Engineer working on backend technologies.