#Inject HttpService inside Guard

5 messages · Page 1 of 1 (latest)

upper flint
#

which option is the right way to inject HttpService inside a guard and why?
option 1: private readonly httpService: HttpService
option 2: @Inject('HttpService') private readonly httpService,

vernal tulip
#

The first one. It's just how standard class injection works

upper flint
#

but can the second one work?
in case i want to import the guard from a library, and i don't want to install @nestjs/axios inside the library

#

i tried it and it didn't work, i want to know if it possible

vernal tulip
#

No. It won't work, and it's not possible