Closed saurabhghewari closed 5 years ago
Remove handler and pre server method string shortcut support.
⬅️ it's in the changlog.
Arrow functions are about as long as the string version so it's deprecated.
Oh, Thank you for the information and also for lightning fast response.
So, according to the change log I need to use request.server.methods.methodName(param1, param2, ...) in pre handler and then return the response.
Thank you once again.
In other words { method : "user.create(payload)", assign : 'createUser' }
should likely become { method : (request) => request.server.methods.user.create(request.payload), assign : 'createUser' }
.
Oh, great that helped me. Thank you very much.
Hi Hapi Team,
I am using Hapijs for developing large projects for my company and would like to continue the same for comming projects.
Right now I am facing some issues migrating from Hapi 16 to Hapi 17. Below is the code
Server.js
User Plugin:-
index.js
user_routes.js
user_config.js
user_methods.js
user_methods.js
============================================================= Code Ends
The above code throws error
Debug: internal, implementation, error TypeError: method.call is not a function at module.exports.internals.Manager.execute (/home/saurabh/node_spikes/hapi_17/node_modules/hapi/lib/toolkit.js:42:106) at Object.internals.handler (/home/saurabh/node_spikes/hapi_17/node_modules/hapi/lib/handler.js:52:48) at exports.execute (/home/saurabh/node_spikes/hapi_17/node_modules/hapi/lib/handler.js:22:37) at internals.Request._lifecycle (/home/saurabh/node_spikes/hapi_17/node_modules/hapi/lib/request.js:276:62) at
at process._tickCallback (internal/process/next_tick.js:188:7)
Hapijs version:- 17.0.1 Nodejs:- 8 Boilerplate: https://github.com/franzip/generator-hapi-api-stack
The same code with some changes in server.js file and hapijs version 16 works perfectly. I am pretty sure the error is at user_config.js -> pre handler -> "user.create(payload)". Please help me in solving this as I need to migrate my code base from Hapijs 16 to Hapijs 17.