Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

with-svelte-kit-guide-changes

Ollie Halliday528739a1f1f5
diff --git a/web/docs/guides/with-sveltekit.mdx b/web/docs/guides/with-sveltekit.mdx
index abbc7801b66..f6079fcb3c0 100644
--- a/web/docs/guides/with-sveltekit.mdx
+++ b/web/docs/guides/with-sveltekit.mdx
@@ -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()
-
- 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)
+ function getProfile(node: HTMLElement) {
+ try {
+ loading = true;
+ const user = supabase.auth.user();
+
+ 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() {