我是新手,所以我不知道如何称呼它。因此,如果之前有人问过这个问题,我深表歉意。我可能想做的是映射数据,但我不知道该怎么做。
componentDidMount() {
fetch("https://reqres.in/api/users?page=3")
.then(data => {return data.json()})
.then(datum => this.setState({client:datum.data}));
}
上面是我的 fetch 组件。从 API 获取的数据包括 id、lastname、firstname。但是,我想将 id 分配为 slug,然后将 firstname+lastname 更改为 name
所以,而不是在客户端数组中看到这个,
id:7
first_name:"Michael"
last_name:"Lawson"
我想看到这样的事情:
slug:7
name:"Michael Lawson"