Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

Issues with Hapi handler toolkit (Node.js)

Solved! Go to Solution.

Hi,

 

i have started a small node.js project where i want to receive data from an API and store it in a MS Sql database for further use by a visualization software (desktop application).

 

I use the module packages hapi, mssql and during the development phase handlebars to check the correct storage and retrieval of the data.

 

The problem is that I am quite a beginner in node.js and javascribt. Also I can't handle hapi's response toolkit h properly and don't quite understand the logic behind it. So I hope that a specialist can help me.

 

 

 

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

const sql = require("mssql");
sql.connect(config).then(pool => { return pool.query("select * from mytable") .then(res => { return h.view('test', { data:res.recordset }); }) .catch(err => { return {}; console.log(err); }); }) } });

These are the errors i get as soon as i make a request via the browser: 

 

ib\toolkit.js:81:29)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async Object.internals.handler (C:\Users\node_modules\@hapi
\hapi\lib\handler.js:46:20)
at async exports.execute (C:\Users\node_modules\@hapi\hapi\lib
\handler.js:31:20)
at async Request._lifecycle (C:\Users\node_modules\@hapi\hapi\
lib\request.js:365:32)
at async Request._execute (C:\Users\node_modules\@hapi\hapi\li
b\request.js:274:9)
Debug: internal, implementation, error
Error: handler method did not return a value, a promise, or throw an error
at exports.Manager.execute (C:\Users\node_modules\@hapi\hapi\l
ib\toolkit.js:81:29)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async Object.internals.handler (C:\Users\node_modules\@hapi
\hapi\lib\handler.js:46:20)
at async exports.execute (C:\Users\node_modules\@hapi\hapi\lib
\handler.js:31:20)
at async Request._lifecycle (C:\Users\node_modules\@hapi\hapi\
lib\request.js:365:32)
at async Request._execute (C:\Users\node_modules\@hapi\hapi\li
b\request.js:274:9)

 

maybe someone can put me on the right course. Or at least tell me what I'm doing wrong. Thanks a lot in advance.

 

 

1 Reply
Highlighted
Solution
Copilot Lvl 2
Message 2 of 2

Re: Issues with Hapi handler toolkit (Node.js)

got allready support from hapi,

 

i missed a return :D