我试图为REST API创建一个接口,但标题中出现错误。我在控制台上附加了代码和图像。我将不胜感激。
import { Customer } from '../components/hero/models/customer';
getCustomerInfo(ndg: string): Observable<Customer> {
const url = `${environment.apiUrl}${environment.ur3Path}cifCustomerDetails/customers/${ndg}`;
return this.apiService.get(url);
}
export interface Customer {
name: string;
surname: string;
emails: Array<Emails>;
}
export interface Emails {
address: string;
}
答案 0 :(得分:1)
您的API响应似乎返回了一个包含电子邮件,姓名和姓氏字段的客户对象。
像这样修改您的界面:
export interface Customer {
customer : CustomerDetails;
}
export interface CustomerDetails{
name: string;
surname: string;
emails: Array<Emails>;
}
export interface Emails {
address: string;
}