I have an Angular Universal Website and I've written the following resolver:
import { Inject, Injectable, OnDestroy } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Subscription, Observable, map, tap, forkJoin, catchError, of, pipe } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import { REQUEST } from '@nguniversal/express-engine/tokens';
import { Request } from 'express';
@Injectable()
export class SessionResolver implements Resolve<boolean>, OnDestroy {
constructor(@Inject(REQUEST) private request: Request) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
console.log(this.request.headers['accept-language']);
return of(false);
}
}
But the moment I do Inject(REQUEST) private request: Request
My page briefly flashes up and then goes white. No other error message is delivered.
How come I can't use this line and what would the alternative be?