Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports. Also, Preboot has moved to https://github.com/angular/preboot - please make preboot-related issues there.
- [X ] bug report
- [ ] feature request
- [ ] support request => Please do not submit support request here, see note at the top of this template.
- [ ] aspnetcore-engine
- [X ] express-engine
- [ ] hapi-engine
Report a bug
Error is thrown
Trying to inject RESPONSE token into an Angular service like this:
@Inject(RESPONSE) private response: any
Also tried to use Injector:
const response = this.injector.get(RESPONSE);
Response object is injected.
Need access to response so I can write a cookie.
Please tell us about your environment:
Angular version: 5.0.0
Platform: all
Other information
I am able to inject REQUEST token successfully but not RESPONSE.
https://github.com/Angular-RU/angular-universal-starter/blob/master/server.ts
try:
res.render('../dist/index', {
req: req,
res: res,
providers: [
{
provide: REQUEST, useValue: (req)
},
{
provide: RESPONSE, useValue: (res)
}
]
});
Could you please make a minimal repro
Ended up solving this by changing:
res.render(join(DIST_FOLDER, 'browser', 'index.html'), { req });
to:
res.render(join(DIST_FOLDER, 'browser', 'index.html'), { req, res });
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Ended up solving this by changing:
res.render(join(DIST_FOLDER, 'browser', 'index.html'), { req });to:
res.render(join(DIST_FOLDER, 'browser', 'index.html'), { req, res });