0

So I have a supabase select query with a JOIN that seems to be working when I log the results to console in the browser, but when I try to use the data from the JOIN, the result is null. The data also shows as null in the terminal console log.

Here is my query:

<script lang="ts" context="module">
import { supabase } from '../supabase';
export async function load({ params }) {
    const slug = params.slug;
    const { data, error } = await supabase
        .from('babies')
        .select(
            'babyName, babyMiddle, babyLast, birthday, gender, lbs, message, oz, weight,  profiles ( first_name, partners_name )'
        )
        .eq('slug', slug);

When I console.log the data object in the browser, it looks like:

{
"babyName": "Test",
"babyMiddle": "",
"babyLast": "Last",
"birthday": null,
"gender": "Boy",
"lbs": null,
"message": "",
"oz": null,
"weight": false,
"profiles": {
    "first_name": "Joe",
    "partners_name": "Jen"
}

But in the terminal console it looks like this (notice profiles is null):

{
  babyName: 'Test', 
  babyMiddle: '',     
  babyLast: 'Last',
  birthday: null,     
  gender: 'Boy',      
  lbs: null,
  message: '',        
  oz: null,
  weight: false,      
  profiles: null
}

Trying to set the data to a store writeable gives me an error because the value is null.

  • Do you see any differences in the [API logs](https://app.supabase.com/project/_/database/api-logs) for the calls from different places? (terminal vs browser) – Mansueli Jul 05 '22 at 19:02

1 Answers1

0

I figured it out. I think it was pulling the data in the browser from cache or something. The profiles table had the wrong permissions policy, once I fixed that and allowed viewing by anyone, the issue was fixed.