Reputation: 620
How can I inject the request or the execution context in a service?
Upvotes: 12
Views: 15395
Reputation: 6290
Since version 6.0, current request can be injected into a service, with REQUEST
token :
export class AppService {
constructor(@Inject(REQUEST) private request) {}
load() {
const user = this.request.user;
}
}
Upvotes: 20