Question:
Can I return more than 50 items from the listOrders function Ask the community
Product:
Wix editor
What are you trying to achieve:
I need to get a list of all members who have a paid payment plan. The function works, but only returns 50 items. I need to return all the members, and there are more than 50. How can I do that?
What have you already tried:
export const myListOrdersFunction = webMethod(Permissions.Anyone, async () => {
let id = “”;
let mbr;
const listedOrders = await orders.listOrders();
//return listedOrders;
for (let i = 0; i < listedOrders.length; i++) {
id = listedOrders[i].buyer.memberId;
ids.push(id);
}
for (let i = 0; i < listedOrders.length; i++) {
console.log(“ids[” + i + “)=”,ids[i]);
}
});
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]
I’m not sure if this code will work, but for now, please try it like this. If it works with a setting of 100, you might want to try increasing it to around 1000.
Thanks, onemoretime,
Good try, but the error says no more than 50. You’d think there was a workaround. I don’t understand why a seemingly arbitrary limit of 50 was put on this function. I’m sure many sites have more orders that 50.
Ron
The default was set to 50, so I thought the specifications might have changed, but it seems the limit is still 50. The last time I tried, it was capped at 50 as well. Such limitations are likely in place to prevent accidental or intentional spamming of requests, which could essentially turn into a form of attack. As the most skilled ninja in our community says, it seems necessary to retrieve items in pages of 50 by using some form of iterative process, incrementing the skip count by 50 each time, and then combining the retrieved items into a single array. As a Japanese person, I fully—or rather, almost—support the ninja’s advice!
That’s actually a good idea. I had thought of something like that, but didn’t put together a way to do it successfully. I’ll give it a try. Thanks to you and your ninja!