I am encountering an issue while attempting to connect hapi.js with mysql. Specifically, when defining a server route, the handler
is failing to return a value.
server.route({
method:'GET',
path:'/hello',
handler:function(request,h) {
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
return ('The solution is: ', results[0].solution)
});
}
});
An error message
Error: handler method did not return a value, a promise, or throw an error
is being displayed.
Despite my attempt to return
('The solution is: ', results[0].solution)
, it does not resolve the issue.
The console output shows The solution is: 2
, however, an error is received in the browser.
Your help on this matter would be greatly appreciated. Thank you