Using Hapi v17, I'm just trying to make a simple web API to start building my knowledge, but I always get an error every time I test the created GET methods. Below is the code I'm running:
'use strict';
const Hapi = require('hapi');
const MySQL = require('mysql');
const server = new Hapi.Server({
host: 'serverName',
port: 8000
});
const connection = MySQL.createConnection({
host: 'host',
user: 'root',
password: 'pass',
database: 'db'
});
connection.connect();
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);
});
The following is the error:
Debug: internal, implementation, error
TypeError: reply is not a function
at handler (/var/nodeRestful/server.js:26:11)
I'm not sure why there is a problem with calling the response function, but right now this is a fatal error.
source
share