https://supabase.com/ logo
Join DiscordCommunities
Powered by
# javascript
  • d

    darklord

    01/25/2022, 4:36 PM
    @stelofo You can access the public url from dashboard by right clicking on it. It will be similar to your supabase app URL with .in domain. And then you can copy the relative URL from there and paste it in ur ENV file and access it from your front end. ( Don't forget to append the filename) with the relative URL.
  • a

    Ahlin Chan

    01/26/2022, 12:01 AM
    How can I achieve something like this
    Copy code
    sql
    select id from servers where count(select * from server_bots where servers.id = server_bots.id) < 25;
    Using
    @supabase/supabase-js
  • m

    mitul

    01/26/2022, 2:25 AM
    this is a silly question but what's the best way to render a list of images from storage? im not sure how to map over the list and convert each img in to a blob
    Copy code
    js
        async function getPath() {
          try {
            setLoading(true)
            
            let { data, error, status } = await supabase.storage
            .from("user-library")
            .list("", {
              limit: 100,
            })
            if(error) {
              throw error
            }
            const imageURL = data.map(item => URL.createObjectURL(item)) /* THIS LINE */
            console.log(imageURL)
    
          } catch (error) {
            console.log("error", error);
          }
        }
    g
    • 2
    • 4
  • m

    mitul

    01/26/2022, 2:29 AM
    oh am i supposed to list and then run another function to download from that list based on
    name
    of each image?
  • m

    mitul

    01/26/2022, 3:07 AM
    ok i did that, works fine but dont think its the right way to do it 🤔
  • g

    garyaustin

    01/26/2022, 3:09 AM
    list of images
  • a

    Ahlin Chan

    01/26/2022, 2:43 PM
    How can I achieve something like this
    Copy code
    sql
    select id from servers where count(select * from server_bots where servers.id = server_bots.id) < 25;
    Using
    @supabase/supabase-js
    What i want to achieve is that i want to obtain an id for a server which has less than 25 bots registered in it. To do this with SQL i can use
    count(...)
    which will count the entries that has the same server id. I'm aware i can retrieve the entries in
    server_bots
    that has the same server id then i count them using if statement in JavaScript; and i repeat till i get a server id that points to a server that has less than 25 bots, but this practice seems to be bad as it will be expensive when the number of servers increase. i want to know what is better way to do this Using
    @supabase/supabase-js
    , thank you!.
    s
    • 2
    • 3
  • z

    ze

    01/26/2022, 6:34 PM
    Hello, i have set up a database and added RLS to the tables, but added no rules yet. I have noticed that if i use the supabase js client i can't get any results back, but if i use curl or postman, for instance, i do get the rows back
    j
    • 2
    • 4
  • z

    ze

    01/26/2022, 6:35 PM
    any idea on why this would be? I've looked at the source code but i can't see anything out of place, the headers are pretty much the same
  • j

    jonny

    01/27/2022, 6:34 PM
    RLS enabled
  • a

    a99111cc042b477e9f22eafe7

    01/27/2022, 8:18 PM
    is there any reason why my await supabase.update() call which I am looping are not closing connections ? I am awaiting to resolve promise before going to next one but after 900~ calls I am getting
    Copy code
    {
      message: 'FetchError: request to https://xxx.supabase.co/rest/v1/episodes?select=id%2Cduration&offset=0&limit=1 failed, reason: connect EHOSTUNREACH xx',
      details: '',
      hint: '',
      code: 'EHOSTUNREACH'
    }
  • t

    ThePhilip

    01/28/2022, 3:30 AM
    What’s the correct format to insert a date
  • g

    garyaustin

    01/28/2022, 3:41 AM
    Just an idea: https://github.com/supabase/supabase/discussions/2839
  • b

    beru

    01/28/2022, 10:25 AM
    does anyone know why
    auth.user()
    doesn't work in the
    load()
    function in sveltekit? it always returns
    null
    , even though it works fine in the regular script tags. in the load function, i'm trying to query from a table with a rls policy
    auth.role() = 'authenticated
    , but it keeps failing. changing the check with
    auth.role() = 'anon'
    works for some reason. i'm guessing this is related to the
    auth.user()
    returning
    null
    .
    c
    v
    • 3
    • 18
  • c

    chipilov

    01/28/2022, 10:41 AM
    auth.user() returns null in SvelteKit load()
  • a

    AmusedGrape

    01/28/2022, 2:25 PM
    i'm trying to use realtime but it doesn't seem to notice when updates are made,
    Copy code
    ts
      supabaseServer.from<Workspace>('workspaces').on('UPDATE', (payload) => {
        console.log(payload)
      }).subscribe();
    am I doing something wrong? thanks!
    g
    p
    • 3
    • 41
  • g

    garyaustin

    01/28/2022, 3:54 PM
    Realtime update not working
  • p

    Peter Hase

    01/30/2022, 9:58 PM
    Hey all, I am using Supabase Auth in a NextJS App and I am not getting the
    SIGNED_IN
    event in
    supabase.auth.onAuthStateChange
    anymore (
    SIGNED_OUT
    works). Does anyone know what the cause could be? I am using a context where I listen to the auth changes, but for some reason, after receiving the callback from the provider, the auth listener does not trigger the login event. The auth context &
    _app.tsx
    for reference: https://gist.github.com/PedroHase/4be266793731879210fec284ac02f4b9
  • a

    AmusedGrape

    01/31/2022, 3:20 AM
    That code is pretty much similar to my code, I can't see any reason why it wouldn't work, maybe try logging the event? could be something else too
  • a

    AmusedGrape

    01/31/2022, 3:20 AM
    For example, here's my Provider code:
    Copy code
    js
    function AuthProvider({ children }: { children: ReactNode }) {
      const [user, setUser] = useState<User | null>();
      const [session, setSession] = useState<Session | null>();
      const [isAuthenticated, setIsAuthenticated] = useState(false);
      const [loading, setLoading] = useState(false);
    
    
      useEffect(() => {
        setLoading(true)
        const session = supabase.auth.session()
        setSession(session)
        setIsAuthenticated(session !== null)
        const user = supabase.auth.user()
        setUser(user)
        setLoading(false)
    
        supabase.auth.onAuthStateChange(async (event, session) => {
          let newUser = supabase.auth.user();
    
          setUser(newUser)
    
          if (newUser && event === 'SIGNED_IN') {
            const r = fetch(`${process.env['NEXT_PUBLIC_API_ENDPOINT']}/api/v1/supabase/set`, {
              method: 'POST',
              credentials: 'include',
              headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${session?.access_token}`
              },
              body: JSON.stringify({ event, session }),
            })
          }
        })
      })
    
      return (
        <AuthContext.Provider value={{
          session: isAuthenticated ? supabase.auth.session() : null,
          user,
          loading,
          login: async (redirect?: string) => {
            await supabase.auth.signIn({ provider: 'discord' }, { redirectTo: redirect })
          },
          logout: async () => {
            await supabase.auth.signOut()
          },
        }}>
          {children}
        </AuthContext.Provider>
      )
    }
  • p

    Peter Hase

    01/31/2022, 9:15 AM
    Thanks for the reply @AmusedGrape , yes it is very strange. I have a previous version of my code that has the same provider code and it works flawlessly, yet in my main code the ˋSIGNED_INˋ event isn’t triggered. Could it be that the event listener for some reason is set up after the token is set in local storage?
    s
    • 2
    • 6
  • s

    silentworks

    01/31/2022, 9:54 AM
    SIGNED_IN event not triggered
  • d

    DNI9

    02/01/2022, 7:44 PM
    Hi everyone, I'm working on a personal project with supabase and nextjs. Currently I'm facing a strange issue, when I call
    supabase.auth.session()
    or
    await supabase.from('profiles').select()
    on nextjs page it works as expected but when I call these on
    getStaticProps
    , it just returns
    null
    or
    Copy code
    {
      error: null,
      data: [],
      count: null,
      status: 200,
      statusText: 'OK',
      body: []
    }
    If anyone faced this, or have any idea what's wrong, please share.
    g
    • 2
    • 2
  • s

    stelofo

    02/01/2022, 7:53 PM
    hey everyone, I got a pesky issue that probably has an easy fix but I can't figure it out - I posted it on SO but figured someone here might have a better answer https://stackoverflow.com/questions/70945990/authenticated-user-shows-up-in-console-log-but-cant-access-the-object
  • s

    stelofo

    02/01/2022, 7:54 PM
    Probably just related to the way I set up context (did it following a tutorial) but got me really stuck
  • g

    garyaustin

    02/01/2022, 8:06 PM
    You are probably getting your user variable you use in the code, before the signIn is actually finished. auth.user() will be null before signIn is completed.
    s
    • 2
    • 2
  • g

    garyaustin

    02/01/2022, 8:07 PM
    next.js getStaticProps
  • j

    jesucrypto

    02/02/2022, 4:25 PM
    hi, is there any way to update password without logging in?
  • m

    Morza (Chris)

    02/02/2022, 5:50 PM
    Is there any documentation on simple ways to update foreign tables w/ a many-to-many relationship ie: client_language: client_id, language_id
  • t

    Taner Nill

    02/02/2022, 7:48 PM
    Hi! I've been struggling to implement this API routes feature that Next JS has on pure react JS... and can't seemingly find the answer....
1...454647...81Latest