【发布时间】:2021-10-29 17:17:14
【问题描述】:
在 setState 我收到这个 TS 错误:
“类型 'AxiosResponse' 缺少来自类型 'countries[]' 的以下属性:length、pop、push、concat 和 26 more.ts(2740)”
谁能建议哪里出了问题/在哪里使用 :countries[] ?
export interface IProfileEditorState {
countries: countries[];
}
interface countries {
countryID: string;
countryName: string;
label: astring;
value: string;
isDirector: number;
}
// Temp
public getCountrys() {
axios
.get('https://func-myportal-dev.azurewebsites.net/api/GetCountries?code=j0xGK8L6iRXpZqR3DgaDRoI/H/qjGZSGdBPIY9rZU84uH4SUa80noQ==')
.then(res => {
this.setState({countries: res});
})
// Error catching
.catch(error => this.setState({ error, isLoading: false }));
}
【问题讨论】:
标签: typescript axios