Accessing Supabase user data in custom JS?

I need to access information about the current authenticated user as part of some custom JS code I’m running in an on page load workflow.

When I click the user variable in the WeWeb js editor I get something like pluginVariables[/* supabaseAuth user */ '(variable uuid)']['user']

I tried using wwLib.wwVariable.getValue('variable uuid') in my code but it returns undefined. Is there a different way to access plugin variables in code?

Thank you!

GD

This is the approach. You can do something like

let my_user_data = pluginVariables[/* supabaseAuth user */ '(variable uuid)']['user']
// and then just access the properties via the dot notation such as
console.log(my_user_data.email) 
//...

This is just a pseudo code, but still.

Thanks, that’s helpful.

In reference to your (now deleted) initial reply, I’m not using the “call postgres function” action because this is a middle piece of the functionality I’m trying to implement so it’d be unwieldy to do just this one middle thing outside of my js code.

Your suggestion did get me thinking about why I was trying to access Supabase from within the worker though. I think the operating assumption was that it would somehow be more efficient since I need to pass the output of that worker to a second worker, but that doesn’t make sense at all. So I moved that part of the logic to the main thread and it’s working now! I just used wwLib.wwPlugins.supabase.instance to get the current, authenticated instance.

1 Like

Yes, they should be the same :slight_smile: