Querying Collections with more than 1000 entries

Hi,

I have a collection which has about 5000 entries in it. This collections stores Customer information. I’m trying to get a list of all customers in the collection using the below code:


let options = {
“suppressAuth”: true ,
“suppressHooks”: true
};

let existingCustomers = await wixData.query(“Customers”).limit(1000).find(options);
let allCustomers = existingCustomers.items;
while (existingCustomers.hasNext()) {
existingCustomers = await existingCustomers.next();
allCustomers = allCustomers.concat(existingCustomers.items);
}


However, I keep receiving this error:


{ error:
{ name: ‘Error’,
errorGroup: ‘User’,
code: ‘WD_PERMISSION_DENIED’,
level: ‘warn’
}
}


Does anyone have any advice for how to fix this? Cheers in advance.

Hi Wade,

Please share a link to your site, so we can inspect it and provide you with a solution.

Thanks
Sapir

Hi Sapir,

The link to my site is “https://www.austradev.com/”. This bit of code is specifically in the back-end http-functions.js file around line 70.

Cheers,
Wade

Hi Wade,

Debug your code in order to find the problem.
You can debug HTTP functions by adding console.log() calls to them. The information you log appears in your site’s Developer Console when previewing your site. Nothing is logged to the console when viewing the published version of your site. Since message logging only runs in preview, you need to call the testing version of your endpoints to see what is logged.

To debug using console.log() in an HTTP function:

  1. Add the call to console.log() in your HTTP function’s code.

  2. Save your site.

  3. Preview your site.

  4. Call the testing endpoint (the URL with _functions-dev ) from an external application.

  5. The logged messages appear in your site’s Developer Console.

Have a nice day and best of luck!
Sapir,

was this resolved as i am having similar issues?

Please open a new post with your question, explaining what you have, what is working, and what isn’t.

Closing this thread.