I want to fetch data in backend from "Members/PrivateMembersData" collection. but getting error "Internal application error"

i am trying to fetch user phone number and other data from collection “Members/PrivateMembersData” but getting “WDE0149 internal application error”
below is code snippet

wixData.query(“Members/PrivateMembersData”)
.find()
.then( (results) => {
// handle the results
console.log(results)
return results
} ).catch(error => {
console.error(‘Error querying database:’, error);
return “null”;
//throw error; // Re-throw the error for proper error handling or debugging
});

i tried same with another collection “Members/FullData” now code is running fine and got result in json form . but all values are null. like
items{
loginEmail:null,
firstName:null,
lastName:null,
phone:null,
sluge:“pravin123”,
nickname:“pravindatir”
}

Such ERRORs are caused by wix itself. You can’t do anything about it → wait for 48-hours, if still not gone → contact wix.

but
i tried same code with another collection “Members/FullData” now code is running fine and i got result in json form . but all values are null. like
items={
loginEmail:null,
firstName:null,
lastName:null,
phone:null,
sluge:“pravin123”,
nickname:“pravindatir”
}

Then you have had an error in your results.

Your code is RETURNING → NULL if something went wrong!
Instead you should return → the ERROR

.catch((error)=> {return error;});

And hopefully you do it on backend.

tried your suggestion . still same issue

in collection “Members/FullData” these values are present . but in console still getting null values for fields.

You don’t have permissions maybe?

SETUP:
Your PMD…
2024-01-11 15_29_40-Wix Website-Editor _ WixWorld

  1. Function on BACKEND:
    2024-01-11 15_30_04-Wix Website-Editor _ WixWorld
    2024-01-11 15_29_50-Wix Website-Editor _ WixWorld

  2. Code running on BACKEND…
    2024-01-11 15_30_31-Wix Website-Editor _ WixWorld

Not logged-in as SUPER-USER… (ADMIN)…no results !!!

Logged-in as SUPER-USER… (ADMIN)… —> RESULTS !!!

Got it, thanks. One more question: I want to add user login functionality through phone number and OTP. For this, I want to retrieve the email address by passing its phone number in the backend. So, suppose I write this code as an admin and publish the website. Will this code work for website users?

An ordinary user gets ACCESS to his OWN PRIVATE-DATA → when he is logged-in!
But what you want is to login the USER by his phone-number, which is part of his PRIVATE-DATA.

  1. Take a look, which data you can get out of PUBLIC-DATA.
    You will need e-mail and phone-number for your purposes right?

  2. So if the PUBLIC-DATA do not provide those two, what you can do else?

We do not forget → our aim is to get →
a) user-email → because you will need that to be able to login
b) user-phone-number → this is what you want to achieve → LOGIN by PHONENUMBER

So —> USER TYPES IN his → PHONENUMBER → you get that phonenumber → making a search for the corresponding e-mail in the background to replace the phonenumber by email → to be able to login the user.

BYPASS-LOGIN!!!

At least you still can open your own additional database, where you can store the phonenumber and email maybe + user-id in an own separated DATABASE.

This can later be used for your purposes.strong text