private readonly 구문을 사용함녀 동일한 위치에서 즉시 공급자를 선언하고 초기화 할 수 있게 함@Injectable()
export class HttpService<T> {
constructor(
@Optional() @Inject('HTTP_OPTIONS') private readonly httpClient: T
) {}
}
// 이것이 우리가 HTTP_OPTIONS 커스텀 토큰을 포함
import { Injectable, Inject } from '@nestjs/common';
@Injectable()
export class HttpService<T> {
@Inject('HTTP_OPTIONS')
private readonly httpClient: T;
}
이렇게 만든 공급자는 Module에 provider 부분에 추가해야함니다