-
Hi All... I wonder how can I make an injection to the controller.
any suggests? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I am not sure you can. Where do you intend to get the auth object you are passing to your UserService from? Instead, I would suggest you should abstract the logic in your UserService that needs the auth object into a middleware. |
Beta Was this translation helpful? Give feedback.
-
I think it would be better to use the auth package provided by Adonis. You will have |
Beta Was this translation helpful? Give feedback.
-
Hi... and then in UserController inside the constructor : |
Beta Was this translation helpful? Give feedback.
Hi...
I found the solution...
in the middleware
I use the ioc.bind to return the new UserService.
and then in UserController inside the constructor :
this.userService = use('UserService')