Using Hapi v17, I am just trying to make a simple web API to start building my knowledge, but I keep getting an error every time I test the GET methods built out. Below is the code I am running:
'use strict';
const Hapi = require('hapi');
const MySQL = require('mysql');
//create a serve with a host and port
const server = new Hapi.Server({
host: 'serverName',
port: 8000
});
const connection = MySQL.createConnection({
host: 'host',
user: 'root',
password: 'pass',
database: 'db'
});
connection.connect();
//add the route
server.route({
method: 'GET',
path: '/helloworld',
handler: function (request, reply) {
return reply('hello world');
}
});
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});
Below is the error I am getting:
Debug: internal, implementation, error
TypeError: reply is not a function
at handler (/var/nodeRestful/server.js:26:11)
I am unsure as to why there is an issue calling the reply function, but it is a fatal error as of right now.