我对本地api网址有疑问,我使用slim做我的api
我看到您没有以您的状态存储api结果。我怀疑这可能是问题所在。请检查下面的代码,它可能会做您想要的事情。
componentDidMount() {
fetch('api/public/all').
then(res=>res.json()).
then(parsedJson => {
const items = parsedJson.result.map(data => ({
id: `${data.id}`,
firstName: `${data.first_name}`,
lastName: `${data.last_name}`,
country: `${data.country}`,
position: `${data.position}`
}));
this.setState({ items });
})
}