Saving Id from a Supabase response in Plasmic to be used on another page

What are you trying to do? (please be as specific as possible and include relevant screenshots, code snippets, and reproduction steps)

Hi! I have sent data to a supabase database. I want to save the Id from the response that is sent back and then use the Id to perform a query on another page. Would anyone know how to do so in Plasmic? How would I create a variable to be used across pages in plasmic? (Sorry for the noob question)

What have you tried so far? (please link relevant docs and other forum posts)

I have tried creating a variable to be used across pages but it seems I am unable to do so.

Relevant links:

Hello @aihe_team,

You can use the $steps variable to get the ID from the inserted element and save it somewhere else like localStorage, to be accessed by another page.

Thank you @icaro_guerra This might be a silly question, but how do I get access to the response object?

In the same place you created this interaction, you can create another one that has access to the response. It will be saved in the $steps variable.

Thank you @icaro_guerra I’ve tried and this is what steps shows me. I am missing something somewhere. Sorry for the inconvenience!

It’s going to be in $steps["updateSupabaseDatabase"] or, in general, $steps[CAMEL_CASE_NAME_OF_THE_INTERACTION]

Thank you @icaro_guerra

I’m doing something wrong because $steps["updateSupabaseDatabase"] results in undefined.

I’ve executed a prior step of inserting to the database but I’m doing something wrong somewhere.

Can you try clicking this icon in the interactions modal to cache the result of the step?

Thank you @icaro_guerra. I don’t have that button. :sweat_smile:

Sorry about that, it’s a WIP feature that I thought was already released :sweat_smile:.

You can test in Interactive mode or in Preview that $steps will be populated with the correct value after the interactions are ran. Try console.log($steps["updateSupabaseDatabase"]).

Thank you @icaro_guerra

I’ve tried but no luck. Here is a video of what I think is the flow you asked me to try out and the result.

Even if it says it’s undefined in the preview, you can save the value $steps[“updateSupabaseDatabase”] and it will happen when you click the button and start all the interactions. Clicking execute for the integration won’t cache the $steps the result.

@icaro_guerra Thank you very much! I will give it a try! Sorry for the late response!

Hi @icaro_guerra I’m very grateful for all your assistance.

I tried as you suggested and now have access to the response object that is returned.

I’m going to try to figure out how to save to localStorage

I have added a picture below for others to know how to try out console.log() in plasmic.

Thank you again! You are the best!

I was able to access localStorage too and access the variable on another page. Thank you very much. Please consider this issue closed. :raised_hands: :medal_military:

1 Like