NestJS · Junior · Question 28 of 75
How do you register a plain value as a provider, e.g. a config object?
providers: [{ provide: "APP_CONFIG", useValue: { retries: 3 } }]- 1With
new Provider() - ✓Correct answer: With
useValue, then inject it with@Inject('APP_CONFIG') - 3It's impossible; providers must be classes
Explanation
Custom providers also support useClass, useFactory and useExisting. Tokens can be strings, symbols or classes.