Ape R Us
04/10/2022, 11:53 PMNeedle
04/10/2022, 11:53 PM/title
command!
We have solved your problem?
Click the button below to archive it.fernandolguevara
04/11/2022, 12:30 AMNeedle
04/11/2022, 12:30 AMApe R Us
04/11/2022, 12:32 AMApe R Us
04/11/2022, 12:33 AMimport supabase from '$lib/db';
export const get = async () => {
try {
const { data: events, error } = await supabase.from('event').select('*');
if (error) throw error;
return {
body: {
events
}
};
} catch (e) {
console.log({ e });
}
};
and i call it like this
{#if events}
{#each events as profile}
<div class="flex space-x-10 ">
<div>{profile.name}</div>
<div>{profile.is_draft}</div>
<div>{profile.organiser}</div>
<div>{profile.user_id}</div>
</div>
{/each}
{/if}
Ape R Us
04/11/2022, 12:34 AMApe R Us
04/11/2022, 12:34 AMexport const eventStore = (() => {
const { subscribe, update, set } = writable({
allTask: []
});
return {
subscribe,
update,
set,
get: async () => {
try {
let { data, error } = await supabase.from('event').select('*');
update((state) => {
state.allTask = data;
return state;
});
// update((state) => (state = { ...state, allTask: data })); //this is another way of writing it
if (error) throw error;
} catch (e) {
console.log(e.message);
} finally {
console.log('hey');
}
}
};
})();
and i call it like this
{#await eventStore.get() then re}
{#each $eventStore.allTask as event}
<div class="mt-10">{event.name}</div>
{/each}
{/await}
Ape R Us
04/11/2022, 12:35 AMexport const user = readable(null, (set) => {
set(supabase.auth.user());
const unsubscribe = supabase.auth.onAuthStateChange((_, session) => {
session ? set(session.user) : set(null);
});
return () => {
unsubscribe.data.unsubscribe();
};
});
garyaustin
04/11/2022, 12:49 AMApe R Us
04/11/2022, 1:00 AMApe R Us
04/11/2022, 1:03 AMgaryaustin
04/11/2022, 1:09 AMApe R Us
04/11/2022, 1:12 AMApe R Us
04/11/2022, 1:13 AMApe R Us
04/11/2022, 1:13 AMgaryaustin
04/11/2022, 1:14 AMApe R Us
04/11/2022, 1:14 AMApe R Us
04/11/2022, 1:14 AMApe R Us
04/11/2022, 1:15 AMgaryaustin
04/11/2022, 1:18 AMApe R Us
04/11/2022, 1:23 AMApe R Us
04/11/2022, 1:23 AM