Hello, I'm new to Hapi.js and its 'ext'
I have a problem with this plugin when adding default config with 'onPrehandler' defaultConfig: { auth: false, ext: { onPreHandler: (request, reply)=>{ debug(request) request.query.limit=25; reply.continue(); } } },
the error is "onPreHandler" must be an object
How can I solve it?
I want requests to always have a limit, maybe there is a better way to do this?
Thanks
Hello, I'm new to Hapi.js and its 'ext'
I have a problem with this plugin when adding default config with 'onPrehandler'
`defaultConfig: {
auth: false,
ext: {
onPreHandler: (request, reply)=>{
debug(request)
request.query.limit=25;
reply.continue();
}
}
}, `
the error is `"onPreHandler" must be an object`
How can I solve it?
I want requests to always have a limit, maybe there is a better way to do this?
Thanks
@ds009 Hey, I personally am not sure about it as I didn't have to use it yet. 🤔
I found this example on their [documentation](https://hapijs.com/api#request-lifecycle) though:
```javascript
server.ext({
type: 'onRequest',
method: function (request, reply) {
// Change all requests to '/test'
request.setUrl('/test');
return reply.continue();
}
});
```
Maybe you should pass something like:
```javascript
ext: [{
type: 'onPreHander',
method: (request, reply) => {...}
}]
```
@ds009 glad you got to fix your problem. Would you mind sharing your solution so others who might encounter it in the future could use your answer? Thanks 😁👍
@ds009 glad you got to fix your problem. Would you mind sharing your solution so others who might encounter it in the future could use your answer? Thanks :grin: :+1:
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hello, I'm new to Hapi.js and its 'ext'
I have a problem with this plugin when adding default config with 'onPrehandler'
defaultConfig: { auth: false, ext: { onPreHandler: (request, reply)=>{ debug(request) request.query.limit=25; reply.continue(); } } },the error is
"onPreHandler" must be an objectHow can I solve it?
I want requests to always have a limit, maybe there is a better way to do this?
Thanks
@ds009 Hey, I personally am not sure about it as I didn't have to use it yet. 🤔
I found this example on their documentation though:
Maybe you should pass something like:
@mdibaiee Thank you for your reply, I tried this way but it didn't work. I switched to another solution by not using 'ext'.
@ds009 glad you got to fix your problem. Would you mind sharing your solution so others who might encounter it in the future could use your answer? Thanks 😁 👍
@mdibaiee Sorry, I just wrote a part of routes myself without using this plugin, it's not an elegant solution worth to be shared...