© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4mo ago•
5 replies
jkwok678

Unable to get data using rpc in JS library, but able to in sql editor

I'm looking to use postgis to store a simple table with a name and point value.
Should I add the postgis extension onto the public table?
I've seen tutorials where people create a gis schema and the location table lives there.
But when I've tried to use the js client library.
like
const { data, error } = await supabase
      .schema("gis")
      .rpc("nearby_locations", {
        user_lat: location?.latitude, 
        user_long: location?.longitude, 
        radius_meters: 5000
      });
const { data, error } = await supabase
      .schema("gis")
      .rpc("nearby_locations", {
        user_lat: location?.latitude, 
        user_long: location?.longitude, 
        radius_meters: 5000
      });

I get zero results, even though it works when I run the method

This is what the function looks like
  select
    l.id,
    l.name,
    l.address,
    ST_Y(l.point::geometry) as lat,
    ST_X(l.point::geometry) as long,
    ST_Distance(
      l.point,
      ST_SetSRID(ST_MakePoint(user_long, user_lat), 4326)::geography
    ) as dist_meters
  from gis.locations l
  where ST_DWithin(
    l.point,
    ST_SetSRID(ST_MakePoint(user_long, user_lat), 4326)::geography,
    radius_meters
  )
  order by dist_meters;
  select
    l.id,
    l.name,
    l.address,
    ST_Y(l.point::geometry) as lat,
    ST_X(l.point::geometry) as long,
    ST_Distance(
      l.point,
      ST_SetSRID(ST_MakePoint(user_long, user_lat), 4326)::geography
    ) as dist_meters
  from gis.locations l
  where ST_DWithin(
    l.point,
    ST_SetSRID(ST_MakePoint(user_long, user_lat), 4326)::geography,
    radius_meters
  )
  order by dist_meters;
in the gis schema
running
select * from gis.nearby_locations(51.552188, -0.364495, 5000);
select * from gis.nearby_locations(51.552188, -0.364495, 5000);
in the sql editor on supabase returns a result.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

unable to delete query from sql editor
SupabaseSSupabase / help-and-questions
3y ago
Unable to run any queries in the SQL Editor
SupabaseSSupabase / help-and-questions
3y ago
Error while using SQL Editor
SupabaseSSupabase / help-and-questions
7mo ago
SQL Editor
SupabaseSSupabase / help-and-questions
7mo ago