sync limit param seems not work
Expected Behavior
When I use sync API and set the limit param to 10, I expected the response results length will be 10, And it takes a long time to wait for the response.
const syncRes = await client.sync({
initial: true,
limit: 10,
});
Environment
- Language Version: v12.15.0
- Package Manager Version: 6.13.4
- Operating System: Mac os
- Package Version: 7.14.3
- Which API are you using?: Delivery
I finally find the solution with HTTP API
...
this.requestPrefix = `http://${this.options.host}/spaces/${this.options.space}/environments/${this.options.environment}/`;
...
sync(query: ContentSyncParam) {
const { type, limit, initial, nextPageUrl } = query;
let requestUrl = '';
if (initial) {
// make a request params string
const query = querystring.stringify({ access_token: this.options.accessToken, type, limit, initial });
requestUrl = `${this.requestPrefix}/sync?${query}`;
} else {
assert(nextPageUrl, 'nextPageUrl must not be empty');
requestUrl = `${nextPageUrl}&access_token=${this.options.accessToken}` as string;
}
return axios.get(requestUrl);
}
I also have this problem using the latest version of API, Please fix it.
I am also experiencing this issue.
This does not match the behavior specified in https://www.contentful.com/developers/docs/javascript/tutorials/using-the-sync-api-with-js/
After digging into the code more it seems that this is a case where the docs are not complete. The library is, in fact, limiting each request to the limit count. However, it is automatically performing multiple requests to fetch the next page behind the scenes for you. You can prevent this behavior by passing a second config object to the sync command with the paginate key set to false.
client.sync({initial: true,limit:10},{paginate: false})
Hey @Gorden-Wang 👋 , as I understand this is now solved. Closing the issue for now - feel free to re-open the issue with any additional details.