Angular “获取请求”;没有与此调用匹配的重载“;角度HttpClient

Angular “获取请求”;没有与此调用匹配的重载“;角度HttpClient,angular,typescript,angular-httpclient,Angular,Typescript,Angular Httpclient,我在后端有一个GET方法,在那里我发送一个请求体作为输入,并获取一个结果列表作为返回 现在在我的前端,我有: search(cat: Cat): Observable<Cat[]> { return this.httpClient.get<Cat[]>(this.messageBaseUri+'/search', cat); } 搜索(cat:cat):可观察{ 返回this.httpClient.get(this.messageBaseUri+'/se

我在后端有一个GET方法,在那里我发送一个请求体作为输入,并获取一个结果列表作为返回

现在在我的前端,我有:

  search(cat: Cat): Observable<Cat[]> {
    return this.httpClient.get<Cat[]>(this.messageBaseUri+'/search', cat);
  }
搜索(cat:cat):可观察{
返回this.httpClient.get(this.messageBaseUri+'/search',cat);
}
我收到的错误在VsCode中:

    (parameter) cat: Cat
No overload matches this call.
  Overload 1 of 15, '(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<...>', gave the following error.
    Argument of type 'Cat' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'.
      Property 'observe' is missing in type 'Cat' but required in type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'.
  Overload 2 of 15, '(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<...>', gave the following error.
    Argument of type 'Cat' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'.
      Property 'observe' is missing in type 'Cat' but required in type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'.
  Overload 3 of 15, '(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<...>', gave the following error.
    Type 'Cat' has no properties in common with type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }'.ts(2769)
http.d.ts(939, 9): 'observe' is declared here.
http.d.ts(1049, 9): 'observe' is declared here.
Peek Problem
No quick fixes available
(参数)cat:cat
没有与此调用匹配的重载。
重载1/15'(url:string,选项:{headers?:HttpHeaders{[header:string]:string{string[]};观察:“事件”;参数?:HttpParams{[param:string]:string{[param:string];};reportProgress?:boolean;responseType?:“json”;带凭据?:boolean;}):可观察到),给出以下错误。
“Cat”类型的参数不能分配给“{headers?:HttpHeaders{[header:string]:string{string[];}”类型的参数;注意:“事件;参数?:HttpParams{[param:string]:string};reportProgress?:boolean;responseType?:“json”;带凭证?:boolean;}”。
类型“Cat”中缺少属性“observe”,但在类型“{headers?:HttpHeaders{[header:string]:string | string[]};observe:“events”;params?:HttpParams |{[param:string]:string | string[]};reportProgress?:boolean;responseType?:“json”;with credentials?:boolean;}”中需要属性。
重载15'(url:string,选项:{headers?:HttpHeaders{[header:string]:string{string[]};注意:“响应”;参数?:HttpParams{[param:string]:string{[param:string]:string[]};reportProgress?:boolean;responseType?:“json”;带凭据?:boolean;}):Observable',给出了以下错误。
“Cat”类型的参数不能分配给“{headers?:HttpHeaders{[header:string]:string{string[];}”类型的参数;注意:“response”;params?:HttpParams{[param:string]:string{[param:string];};reportProgress?:boolean;responseType?:“json”;带凭证?:boolean;}”。
类型“Cat”中缺少属性“observe”,但在类型“{headers?:HttpHeaders{[header:string]:string | string[]};observe:“response”;params?:HttpParams |{[param:string]:string | string[]};reportProgress?:boolean;responseType?:“json”;with credentials?:boolean;}”中需要属性。
重载15'(url:string,options?:{headers?:HttpHeaders{[header:string]:string{string[];};observe?:“body”;params?:HttpParams{[param:string]:string};reportProgress?:boolean;responseType?:“json”;with Credentials?:boolean;}):Observable',给出了以下错误。
类型“Cat”与类型“{headers?:HttpHeaders{[header:string]:string | string[];};observe?:“body”;params?:HttpParams{[param:string]:string | string[];};reportProgress?:boolean;responseType?:“json”;带凭证?:boolean;}.ts(2769)
http.d.ts(939,9):“observe”在这里声明。
http.d.ts(1049,9):“observe”在这里声明。
偷窥问题
没有可用的快速修复方法

我在这里读到GET请求不能将body作为输入参数,但是我如何能够通过例如Postman发送请求body并在没有错误的情况下获得返回

没有适合get的身体。您可以传递url和选项以获取请求

您可以在下面的链接中看到get的各种重载

在GET-
、cat
中没有主体,您可以传递带有HttpParams的HttpOptions,等等