#How to filter data onGet?

5 messages · Page 1 of 1 (latest)

marble shoal
#

Hey guys, I have a navigation wich is filled through an api request. As you can see I have a big property path in my return statement. Where I could filter this out before?

export const onGet = async () => {
  const { data } = await supabase
    .from("Pages")
    .select(`WebsiteId(ConfigId(*))`)
    .match({ WebsiteId: 9, URL: "/" })
    .single();

  return data;
};

export default component$(() => {
  const navigation = useEndpoint();

 return (
    <Resource
      value={navigation}
      onPending={() => <div>Loading...</div>}
      onRejected={() => <div>Error</div>}
      onResolved={(nav) => (
        <main>
          <pre>
            {JSON.stringify(nav.WebsiteId.ConfigId.Navigation, null, 2)}
          </pre>
        </main>
      )}
    />
  );
ivory totem
#

Do you want to manipulate the data response? If so you can do it before you return it in the onGet method!

marble shoal
ivory totem
#

Sure! Or just return data.property.property ☺️ But either should work!

marble shoal
#

hmm its npt working :/ everytime the same data