Is this a good example of how to get data from my ...
# help
j
Is this a good example of how to get data from my Tables? I keep getting a error of “cant ….something .0 or .1….
Copy code
import { useEffect, useState } from 'react';
import { supabase } from '../lib/initSupabase';

export default function CountryList() {
  const [countries, setCountries] = useState([]);

  useEffect(() => {
    fetchCountries();
  }, []);

  const fetchCountries = async () => {
    const { data: countries } = await supabase
      .from('countries')
      .select('*')
      .order('name', true);
    setCountries(countries);
  };

  return (
    <ul>
      {countries.map((country) => (
        <li key={country.id}>{country.name}</li>
      ))}
    </ul>
  );
}
n
Hello @justcode123! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! 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.
s
I'm not a React dev but can you provide the full error you are getting and can you also check your network tab to see if the request is being made to Supabase and if there is data in the response.
n
justcode123 (2022-04-12)