Server 500 Error

Hello,
I’m having a hell of a time debugging this code. Any help is GREATLY appreciated!

I have code that determines the user’s emails, phones, and addresses. The problem is that the URL path sometimes contains the ID and sometimes it contains the slug. If I get an ID, I’m fine (I can just call getContactById(ID) ). However, if I get a slug, I’m in trouble. I have to query the PrivateMembersData collection to get the ID and then query Contacts to get the addresses (because addresses doesn’t exist in PrivateMembersData).

My error comes when I try to get the data when I have a slug in the URL. I can’t for the life of me figure out where to even begin. It happens in preview and live.

Thank you,
-A tired and stressed out developer

https://support.wix.com/en/article/live-site-error-error-500-internal-server-error

What are you trying to achieve, is it a profile page, as you can always just do something like this tutorial.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

Also, can you get the id and not the slug for both occasions?

Finally, as it states at the bottom of the message, ‘profile page was delayed by 963ms due to code’, could yu try treating it as a 504 gateway timeout error too.

Unfortunately, I still get the error after refreshing, re-entering the URL, waiting, and even switching browsers.

OH MY LORD!

… … … result.items[0]._id