Problem with connecting Supabase table via REST API

Hi,

I’m trying to set up a REST API data fetcher to a Supabase table that contains article content.

I only want to pull the row that corresponds with the slug of my current page.

Here’s what works already:

https://[my-database].supabase.co/rest/v1/articles?select=*

If I select *, all article objects from the table are pulled correctly. So the connection works. But this query pulls all articles, while I only need the one for the current slug.

https://[my-database].supabase.co/rest/v1/articles?select=*&slug=eq.first-article

If I filter hard-coded for one article (e.g. an article with the slug “first-article”) the API connection works and the current article data is pulled.

But I want to filter for the row corresponding with my current slug.

Here’s what doesn’t work:

https://[my-database].supabase.co/rest/v1/articles?select=*&slug=eq.$ctx.params.slug

https://[my-database].supabase.co/rest/v1/articles?select=*&slug=eq.${ctx.params.slug}

In the network view I see that the parameter is not populated but still sent off as a parameter to Supabase. It stays $ctx.params.slug or ${ctx.params.slug}. See screenshot.

How can I set things up, so the slug of my current page is sent off to Supabase?

Thank you!

Can you share a screenshot of how the API is configured? Specifically the URL dynamic value.

Thanks for asking!

Do you mean the API configuration within Plasmic Studio? I’ve shared it below.

Can you spot a mistake?

Set the URL as a dynamic value then update to this and you should be on your way. The URL added from the left panel in the UI is entered as a string. This will evaluate the variable and concatenate to your base url string.

“https://[my-database].supabase.co/rest/v1/articles?select=*&slug=eq.”+$ctx.params.slug

1 Like

Hey Ryan,

Thanks, you’ve saved my day with your help! - Your approach worked.

Just for further reference, if anybody runs into the same problem:

For me, putting the enhanced URL (with hyphens) into the code editor that opens up when clicking the binding bolt did not work. Somehow the editor messed up and delivered a syntax error. But this could be entirely my fault or system setup.

But what DID work for me was

  1. Just choosing the dynamic field from the data picker first:

pm_sb_1

  1. Then adding the static URL directly in the URL field before the dynamic field:

Meaning, I patched together the static URL and the dynamic field.

Now the REST API connection to Supabase calls the “articles” table and only pulls the article corresponding with the current slug.

Thanks!

1 Like