Skip to content

Commit

Permalink
Merge pull request #67 from storyblok/fix/datasource-sync
Browse files Browse the repository at this point in the history
fix: add the correct way to get the paginated content for datasources
  • Loading branch information
ademarCardoso authored Aug 8, 2023
2 parents a2de721 + 4c08b4c commit d0200ee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tasks/sync-commands/datasources.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SyncDatasources {
const entriesFirstPage = await this.client.get(`spaces/${spaceId}/datasource_entries/?datasource_id=${datasourceId}${dimensionQuery}`)
const entriesRequets = []
for (let i = 2; i <= Math.ceil(entriesFirstPage.total / 25); i++) {
entriesRequets.push(this.client.get(`spaces/${spaceId}/datasource_entries/?datasource_id=${datasourceId}`, { page: i }))
entriesRequets.push(await this.client.get(`spaces/${spaceId}/datasource_entries/?datasource_id=${datasourceId}&page=${i}`))
}
return entriesFirstPage.data.datasource_entries.concat(...(await Promise.all(entriesRequets)).map(r => r.data.datasource_entries))
} catch (err) {
Expand Down

0 comments on commit d0200ee

Please sign in to comment.