Ape R Us
04/13/2022, 7:04 AMimport supabase from '$lib/db';
export const get = async () => {
try {
const { data: events, error } = await supabase
.from('event')
.select('*')
.eq('user_id', auth.users.id));
if (error) throw error;
return {
body: {
events
}
};
} catch (e) {
console.log({ e });
}
};
Needle
04/13/2022, 7:04 AM/title
command!
We have solved your problem?
Click the button below to archive it.Ape R Us
04/13/2022, 7:20 AMtourdownunder
04/13/2022, 11:27 AMconst user = supabase.auth.user()
as per the sample below.
This is from the supabase svelte tutorial I completed about 6 months ago. I don't think anything has changed.
js
async function getProfile() {
try {
loading = true
const user = supabase.auth.user()
email = user.email
let { data, error, status } = await supabase
.from('profiles')
.select(`username, website, avatar_url`)
.eq('id', user.id)
.single()
if (error && status !== 406) throw error
if (data) {
username = data.username
website = data.website
avatar_url = data.avatar_url
}
} catch (error) {
alert(error.message)
} finally {
loading = false
}
}
Needle
04/13/2022, 11:27 AMApe R Us
04/13/2022, 5:50 PMtourdownunder
04/13/2022, 10:10 PM