© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
4 replies
Mr Void

How to know if a public url doesn't exist?

Im trying to fetch a user's avatar from the public bucket.

I wish to know whether the URL is valid or not so that I could use a default URL in case url is invalid. How to achieve this?

export const fetchAvatarUrl = async (userId: string) => {
    const { data } = await supabase.storage
    .from('profile_pictures')
    .getPublicUrl(`${userId}`)

    console.log("avatar url:", data.publicUrl)
}
export const fetchAvatarUrl = async (userId: string) => {
    const { data } = await supabase.storage
    .from('profile_pictures')
    .getPublicUrl(`${userId}`)

    console.log("avatar url:", data.publicUrl)
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Only INSERT if reservation doesn't exist yet.
SupabaseSSupabase / help-and-questions
4y ago
Snippet doesn't exist
SupabaseSSupabase / help-and-questions
6mo ago
How do I update a bucket path or upload if it doesn't already exist?
SupabaseSSupabase / help-and-questions
4y ago
Storage public URL
SupabaseSSupabase / help-and-questions
4y ago