【发布时间】:2021-10-07 20:38:42
【问题描述】:
我是新手,我正在尝试做简单的事情。
我收到来自 BE 的 JSON 数据,如下所示:
{"data":[{"id":"12345",
"name":"Blabla",
"otherName":"3300",
"completeDate":"2021-10-01T05:00:00.000+0000",
"status":"Active",
"location":"572957393.pdf"}]}
现在位置是文件存储在服务器上的位置,我需要将 data.location 与 URL 连接起来,所以当我渲染它时,"572957393.pdf" 我会看到这个"https://www.mypage.com/files/https572957393.pdf"
我认为最好的方法是在 fetch 类方法中使用 .map 方法,但我无法使其工作
获取语句:
fetchData(params, id){
axios({
url:`/admin/${this.state.radioSelect}/detail`,
method:'get',
params
}).then(resp => {
//const updated = resp.data.map(location) => This is where I am trying to use .map method
.then(resp => {
if(resp.data.code == '200'){
this.setState({
pageSize:this.state.pagination.pageSize,
records:resp.data.data,
recordsTableSpin:false,
recordsId:id,
})
}
})
}
你能帮我解决这个问题吗? 谢谢。
【问题讨论】:
标签: javascript reactjs url fetch-api