Angular 如何显示来自用户的FavRecipes(角度)

Angular 如何显示来自用户的FavRecipes(角度),angular,angular-resolver,Angular,Angular Resolver,我正在尝试显示当前登录用户的FavRecipes。 我正在编写asp.net核心MVC+Angular(SPA) 我有一个错误:400(错误请求) 有什么想法吗 我已经尝试过的: 分解器 import {Injectable} from '@angular/core'; import { Resolve, Router, ActivatedRouteSnapshot } from '@angular/router'; import { Observable, of } from 'rxjs';

我正在尝试显示当前登录用户的FavRecipes。 我正在编写asp.net核心MVC+Angular(SPA) 我有一个错误:400(错误请求) 有什么想法吗

我已经尝试过的:

分解器

import {Injectable} from '@angular/core';
import { Resolve, Router, ActivatedRouteSnapshot } from '@angular/router';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { AlertifyService } from '../_services/alertify.service';
import { UserService } from '../_services/user.service';
import { Recipe } from '../_models/recipe';


    @Injectable()
    export class FavRecipesResolver implements Resolve<Recipe[]> {

        constructor(private userService: UserService, private router: Router, private alertify: AlertifyService) {

        }

        resolve(route: ActivatedRouteSnapshot): Observable<Recipe[]> {
            return this.userService.getFavRecipes(route.params.id).pipe(
                catchError(error => {
                    this.alertify.error('Problem retrieving data');
                    this.router.navigate(['/home']);
                    return of(null);
                })
            );
        }
    }
按我的路线

{path: 'my-fav-recipes', component: FavRecipeListsComponent, resolve: {recipes: FavRecipesResolver}},
型号:

export interface User {
    id: number;
    username: string;
    knownAs: string;
    age: number;
    gender: string;
    created: Date;
    lastActive: Date;
    photoUrl: string;
    city: string;
    country: string;
    introduction?: string;
    userPhotos?: UserPhoto[];
    recipes?: Recipe[];
}


export interface Recipe {
    id: number;
    name: string;
    ingredients: string;
    preparationTime: number;
    dateAdded: Date;
    photoUrl: string;
    description?: string;
    recipePhotos?: RecipePhoto[];
}
我应该创建FavRecipes类吗

@编辑

《邮差》中API的回应

在我的用户服务中

getFavRecipes(id: number) {
    return this.http.get(this.baseUrl + 'users/' + id + '/favouriteRecipes');
  }

在Angular中,您在哪里发出HTTP请求?您提到的URL包含一个
未定义的
-''。您能否确认正在进行API调用,并且您正在订阅activatedroute的组件typescript文件中获得结果?如果你发布API响应,那会很有帮助。我已经编辑了帖子
getFavRecipes(id: number) {
    return this.http.get(this.baseUrl + 'users/' + id + '/favouriteRecipes');
  }