Merge pull request #7668 from Hallidayo/with-svelte-kit-changes

fix: with-svelte-kit-guide-changes
This commit is contained in:
Copple authored and GitHub committed 2022-08-10 12:16:55 +02:00
commit 53c469f492
1 file changed
+31 -29
+31 -29
View File
@@ -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() {