Angular Resolver issue

2019-08-19 16:13发布

I am working on angular project where I get Home page ID from ACF options, and then need to send another HTTP request to that page ID.

I have created angular Resolver, but I don't know how to send this multiple request

Is there a way to get home page from option end point and then pass to pages endpoint.

here is the code what I am trying.

export class HomeResolverService implements Resolve<any> {

  constructor(private http: HttpClient) {}

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
    this.http.get<any>(ACF_OPTIONS).subscribe((res) => {
      return this.http.get<any>(HOME_PAGE + res.acf.home_page).pipe(map((optionsData: any) => {
        return optionsData;
      }));
    });
  }
}

But this code return is undefined

0条回答
登录 后发表回答