У меня есть метод GET в моем бэкэнде, где я отправляю тело запроса в качестве ввода и получаю список результатов в качестве возврата.
Теперь у меня в интерфейсе:
search(cat: Cat): Observable<Cat[]> {
return this.httpClient.get<Cat[]>(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
Я читаю здесь https://github.com/github/fetch/issues/635 что запрос GET не может иметь тело в качестве входного параметра, но как я могу отправить тело запроса через Пример Почтальона и получить возврат без ошибки?