如何在没有最大长度数组限制的情况下在 React 中获取数据?
How fetch data in React without max length array limit?
我正在使用 axios 通过 JSONAPI Drupal 模块从无头 Drupal 8 获取数据到我的 React 组件。
当我通过 Postman 发出完全相同的获取请求时(URL 和 headers 相同),我得到了 300+ objects 的数组,但是当从 React 获取时,响应是有限的到 50 objects.
什么限制了我的数组长度以及如何覆盖限制以获得完整数组?
此请求放置在我的 React 项目 App.js 中的 componentDidMount() 中,由 Create-React-App:
创建
axios({
method: 'get',
url: `${prodURL}/jsonapi/node/puzzle/?fields[node--puzzle]=field_filestack_handle,created&filter[eventfilter][condition][path]=field_event_reference.field_event_access_code&filter[eventfilter][condition][value]=${eventAccessCode}&sort=-created`,
auth: {
username: `${fetchUsername}`,
password: `${fetchPassword}`
},
headers: {
'Accept': 'application/vnd.api+json',
'Content-Type': 'application/vnd.api+json',
}
})
.then(response => {
this.setState({
data: response.data.data,
isLoading: false
})
})
.catch(error => console.log(error));
}
您可以使用lodash chunk将数组拆分为长度为50的数组数组
_.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]
JSON API Drupal 模块限制了响应。我应该用 Pagination
我正在使用 axios 通过 JSONAPI Drupal 模块从无头 Drupal 8 获取数据到我的 React 组件。
当我通过 Postman 发出完全相同的获取请求时(URL 和 headers 相同),我得到了 300+ objects 的数组,但是当从 React 获取时,响应是有限的到 50 objects.
什么限制了我的数组长度以及如何覆盖限制以获得完整数组?
此请求放置在我的 React 项目 App.js 中的 componentDidMount() 中,由 Create-React-App:
axios({
method: 'get',
url: `${prodURL}/jsonapi/node/puzzle/?fields[node--puzzle]=field_filestack_handle,created&filter[eventfilter][condition][path]=field_event_reference.field_event_access_code&filter[eventfilter][condition][value]=${eventAccessCode}&sort=-created`,
auth: {
username: `${fetchUsername}`,
password: `${fetchPassword}`
},
headers: {
'Accept': 'application/vnd.api+json',
'Content-Type': 'application/vnd.api+json',
}
})
.then(response => {
this.setState({
data: response.data.data,
isLoading: false
})
})
.catch(error => console.log(error));
}
您可以使用lodash chunk将数组拆分为长度为50的数组数组
_.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]
JSON API Drupal 模块限制了响应。我应该用 Pagination