any idea why i am getting this?
# help
p
any idea why i am getting this?
n
Hello @Paul! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
p
Copy code
export default function Home() {
  const [s3Buckets, setS3Buckets] = useState([])

  const getS3Buckets = async () => {
    let {data: s3_buckets, error} = await supabase
      .from('s3_buckets')
      .select('*')

    if (error) {
      console.error(error.message)
    } else {
      setS3Buckets(s3_buckets)
    }
  }

  useEffect(() => {
    getS3Buckets()
  }, [])
n
šŸ†• Cannot read properties of undefined weird....
p
I have one row in my table. Shouldn't i be getting something back at least?
o
Hi Did you import the supabase dependency?
n
Cannot read properties of undefined weird....
p
import supabase from '../utils/supabase'
o
what is in your ``utils/supabase`` file?
p
Copy code
import {createClient} from '@supabase/supabase-js'

const supabaseUrl = process.env.REACT_APP_SUPABASE_URL
const supabaseAnonKey = process.env.REACT_APP_SUPABASE_ANON_KEY

export const supabase = createClient(supabaseUrl, supabaseAnonKey)
o
hmmm this is weird
p
i know right?
im using Next JS
Vite didn't even want to import the module
o
Vite doesn't want to import the module? This is definitely not normal
p
I was getting module can not be found
exactly the same set up
Copy code
✘ [ERROR] No matching export in "utils/supabase.js" for import "default"

    src/App.jsx:2:7:
      2 │ import supabase from '../utils/supabase'
o
Oooooooh
I KNOW WHY
You're exporting supabase as ``supabase`` not as default
p
Copy code
ā”œā”€ā”€ src
│   ā”œā”€ā”€ App.css
│   ā”œā”€ā”€ App.jsx
│   ā”œā”€ā”€ favicon.svg
│   ā”œā”€ā”€ index.css
│   ā”œā”€ā”€ logo.svg
│   └── main.jsx
ā”œā”€ā”€ tailwind.config.js
ā”œā”€ā”€ utils
│   └── supabase.js
└── vite.config.js
o
Copy code
ts
import {createClient} from '@supabase/supabase-js'

const supabaseUrl = process.env.REACT_APP_SUPABASE_URL
const supabaseAnonKey = process.env.REACT_APP_SUPABASE_ANON_KEY

export const supabase = createClient(supabaseUrl, supabaseAnonKey)
If you're using this code, you need to import supabase as
Copy code
ts
import { supabase } from '../utils/supabase';
p
ah shit! lol I
o
If you want to import it as ``import supabase from '../utils/supabase'``, in that case simply ``export default``
p
that works...by NextJS lol
sorry i haven't used React for a few months you know stuff just vanishes from your brain
o
It's Javascript modules, not related to react šŸ˜›
p
ok ill refrash...i have touched anything code related for a few months
lol
n
Thread was archived by @Paul. Anyone can send a message to unarchive it.