我的服务器返回了像buildings : [record1, record2, ...]
这样的响应,我只想从中获取数组。我该如何从Promise中获取只有数组的结果?我尝试过一些async/await的方法,但不知道如何在这段代码中使用:
setupImpagination() {
....
fetch(pageOffset, pageSize, stats) {
return fetch(`http://localhost:3000/api/building/all?skip=${pageOffset}&limit=${pageSize}`)
.then(response => {
console.log('response.json() => ',response.json());
response.json()
})
.catch((error) => {
console.error(error);
});
}
});
}
fetch
前面加上async
,然后它就有效了。 - imalik8088