mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Merge pull request #7668 from Hallidayo/with-svelte-kit-changes
fix: with-svelte-kit-guide-changes
This commit is contained in:
1 file changed
+31
-29
@@ -256,28 +256,28 @@ Let's create a new component for that called `Profile.svelte`.
|
||||
let website = null
|
||||
let avatar_url = null
|
||||
|
||||
async function getProfile() {
|
||||
try {
|
||||
loading = true
|
||||
const user = supabase.auth.user()
|
||||
function getProfile(node: HTMLElement) {
|
||||
try {
|
||||
loading = true;
|
||||
const user = supabase.auth.user();
|
||||
|
||||
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)
|
||||
supabase
|
||||
.from("profiles")
|
||||
.select(`username, website, avatar_url`)
|
||||
.eq("id", user?.id)
|
||||
.single()
|
||||
.then(({ data, error, status }) => {
|
||||
if (data) {
|
||||
username = data.username;
|
||||
website = data.website;
|
||||
avatar_url = data.avatar_url;
|
||||
}
|
||||
if (error && status !== 406) throw error;
|
||||
});
|
||||
} catch (error: any) {
|
||||
alert(error.message);
|
||||
} finally {
|
||||
loading = false
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,15 +415,17 @@ Let's create an avatar for the user so that they can upload a profile photo. We
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
async function downloadImage() {
|
||||
try {
|
||||
const { data, error } = await supabase.storage.from('avatars').download(path)
|
||||
if (error) throw error
|
||||
|
||||
src = URL.createObjectURL(data)
|
||||
} catch (error) {
|
||||
console.error('Error downloading image: ', error.message)
|
||||
}
|
||||
function downloadImage() {
|
||||
supabase.storage
|
||||
.from("avatars")
|
||||
.download(path)
|
||||
.then(({ data, error }) => {
|
||||
if (error) throw error;
|
||||
src = URL.createObjectURL(data);
|
||||
})
|
||||
.catch((error) =>
|
||||
console.error("Error downloading image: ", error.message)
|
||||
);
|
||||
}
|
||||
|
||||
async function uploadAvatar() {
|
||||
|
||||
Reference in new issue
Block a user