Why does member query result with an array of 0?

What is wrong about this code? I have been tried to use it on member pages and other pages. Results object returns 0 array.

import wixUsers from 'wix-users';
import wixData from 'wix-data';

$w.onReady(function () {
    let user = wixUsers.currentUser;
    let id = user.id
        .eq("_id", wixUsers.currentUser.id)
        .then((results) => {
            if (results.items.length > 0) {
                name = results.items[0].name;
                    .eq("person", name)



Note that the PrivateMembersData collection has Read permission for Site Member Author only.

You should do the query in the backend and use the SuppressAuth option set to true as demonstrated in the following code snippet:

import wixData from 'wix-data';

// ...

let options = {
    "suppressAuth": true,
    "suppressHooks": true

  .then( (results) => {
    if(results.items.length > 0) {
      let items = results.items;
      let firstItem = items[0];
    } else {
      // handle case where no matching items found
  } )
  .catch( (error) => {
    let errorMsg = error.message;
    let code = error.code;
  } );

I have coded in the backend and solved the issue. It was just a part of code on that page, I have changed all of it after. Thank you for your reply.

1 Like