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

    Martin INDIE MAKERS

    03/08/2022, 4:44 PM
    For people with the same issue as me, it come from http plugin in capacitor. it can't upload multipart... Here is my solution:
    Copy code
    typescript
    import type { SupabaseClientOptions } from '@supabase/supabase-js'
    import { createClient } from '@supabase/supabase-js'
    import type { HttpOptions } from '@capacitor-community/http'
    import { Http } from '@capacitor-community/http'
    
    export const useSupabase = () => {
      const options: SupabaseClientOptions = {
        autoRefreshToken: true,
        persistSession: true,
        detectSessionInUrl: false,
        fetch: (requestInfo, requestInit) => {
          if (requestInit?.method === 'POST' && requestInfo.toString().includes('/storage/')) {
            return fetch(requestInfo, {
              method: requestInit?.method,
              headers: requestInit?.headers,
              body: requestInit?.body,
            })
          }
          return Http.request({
            url: requestInfo.toString(),
            method: requestInit?.method,
            headers: requestInit?.headers as any || {},
            data: requestInit?.body,
          })
            .then((data) => {
              const resp = new Response(JSON.stringify(data.data), {
                status: data.status,
                headers: data.headers,
              })
              return resp
            })
        }
      }
      return createClient(supabaseUrl, supabaseAnonKey, options)
    }
  • c

    cbert

    03/08/2022, 5:28 PM
    hi everyone, I'm getting the error
    Copy code
    message: 'null value in column "id" of relation "goals_blocked" violates not-null constraint',
    after running an upsert as follows:
    Copy code
    const { data: goalBlocked, error } = await supabase.from('goals_blocked').upsert({
            id: body.id,
            user_id: body.userId || locals.user.id,
            workspace_id: body.workspaceId,
            goal_id: body.goalId,
            is_blocked: body.isBlocked,
            updated_at: new Date().toISOString()
        })
    See screenshot for table in supabase. I can see why the error happens, if there is no entry yet, the id passed is
    null
    , but isn't that the idea of upsert? If there is no id it creates an entry if not it updates it? Thanks for any help! EDIT: current workaround is to generate uuid in js as fallback:
    id: body.id || uuidv4(),
  • e

    elliott

    03/08/2022, 5:56 PM
    I’m curious if anyone has a good solution for fetching the profile often. I need it on just about every page of my app, so I end up calling “select profile” before the other calls of every page. This seems really redundant.
  • e

    elliott

    03/08/2022, 5:56 PM
    Can/ should it be stored on the user in some way?
  • d

    DanMossa

    03/08/2022, 8:17 PM
    Cache it?
  • p

    Pukima

    03/09/2022, 12:19 PM
    https://stackoverflow.com/questions/71398027/supabase-updating-array-passes-array-from-before-as-a-value
    g
    • 2
    • 7
  • p

    Pukima

    03/09/2022, 12:19 PM
    Array not updating correctly ^ ||At least how I want it||
  • g

    garyaustin

    03/09/2022, 4:09 PM
    array return data from select
  • p

    Pukima

    03/09/2022, 6:04 PM
    The inserting does not actually insert. It does nothing to be exact! I have this code:
    Copy code
    js
    const { data: newData } = await supabase
                .from('messages')
                .insert([{ message_id: `${data.length + 1}`, title: `${title}`, message: `${message}`, created_at: `${new Date()}` }]);
    And this is my table config:
  • s

    Scott P

    03/09/2022, 6:09 PM
    You're most certainly experiencing an error then.
    const {data. error} = /* supabase call */
    will tell you what the problem is.
  • p

    Pukima

    03/09/2022, 6:46 PM
    Thx that helped!
  • k

    kresimirgalic

    03/10/2022, 6:56 PM
    Hey supabase people, I am starting a new project in react native and I wanted to know how’s yours experience with supabase inside react native? Did you had any issues connecting etc.?
    o
    f
    • 3
    • 2
  • o

    Olyno

    03/11/2022, 1:52 PM
    React native feedback
  • t

    TMShader

    03/11/2022, 9:55 PM
    Is there a way to check if an email has already been registered with?
    g
    d
    • 3
    • 34
  • g

    garyaustin

    03/11/2022, 11:03 PM
    Check if email registered
  • a

    asleepingpanda

    03/12/2022, 8:47 PM
    Anybody have any trouble using Supabase server side? I'm passing in my user's access token and calling
    supabaseClient.auth.setAuth(access_token)
    , but I get
    null
    for the return value of
    user
    every time with no
    error
    being thrown..?
    g
    • 2
    • 11
  • g

    garyaustin

    03/12/2022, 9:12 PM
    setAuth
  • u

    upwell

    03/13/2022, 4:02 PM
    Hello, I have following query, the inner join contains relationships between two profiles, however I would like to filter out those relationships and return all profiles where the inner joined table doesnt contain relationship. Problem is that I delete these rows, so following query doesn't return anything - because obviously there is no row in the inner table. Could someone give me a hint how else I could approach it?
  • u

    upwell

    03/13/2022, 4:03 PM
    I could get the linked ones and all of them and filter them in javascript, but It might be possible to just do it with query somehow.
  • g

    garyaustin

    03/13/2022, 4:32 PM
    It might be worth considering a view that only shows rows without the relationship and query that.
  • u

    upwell

    03/13/2022, 4:33 PM
    Good point, I might do that, I just tried looking if there is not other simple way on frontend as I don't touch the backend when I don't have to haha
    g
    • 2
    • 1
  • u

    upwell

    03/13/2022, 4:33 PM
    but I will, thank you
  • g

    girishso

    03/14/2022, 2:21 AM
    Need help with CORS error in Elm or with
    fetch
    ... https://discord.com/channels/839993398554656828/843999948717555735/952444999549730846
  • d

    DanMossa

    03/14/2022, 3:55 AM
    Don't forget that views have RLS by the user that created it
  • l

    Lukas

    03/14/2022, 4:23 AM
    how do I convert json to binary? (ping me!)
  • f

    Fainaru

    03/14/2022, 5:49 AM
    Hello, I have the following query, when I use ionic lab it gives me an error when making a refresh token and then it gives me this error when querying data
  • p

    pheralb

    03/14/2022, 2:21 PM
    Good morning community, I have a question. I am developing an application with Nextjs which I use Supabase as Backend. The login is done in the following way:
    Copy code
    ts
     const handleLogin = async () => {
        const { error } = await supabase.auth.signIn({provider: "github"});
        if (error) {
          alert(JSON.stringify(error));
        }
      };
    and I get the user. But when I access a path protected with getServerSideProps:
    Copy code
    ts
    export const getServerSideProps: GetServerSideProps = async ({ req }) => {
      const { user } = await supabase.auth.api.getUserByCookie(req);
      if (!user) {
        return { props: {}, redirect: { destination: "/" } };
      }
      return { props: { user } };
    };
    the user is always null. My "pages/api/auth.ts":
    Copy code
    ts
    export default function handler(req: NextApiRequest, res: NextApiResponse) {
      supabase.auth.api.setAuthCookie(req, res)
    }
    . Does anyone know how to get user once logged into the protected page? 🤔
    s
    • 2
    • 2
  • s

    silentworks

    03/14/2022, 2:41 PM
    NextJS with Supabase
  • s

    swiss

    03/14/2022, 10:34 PM
    How do I query for all rows of a table that has a foreign key, by a column on the table of that foreign key?
    g
    • 2
    • 2
  • b

    BallisticSwami

    03/15/2022, 10:01 AM
    How do I know if a file has finished uploading?
    d
    • 2
    • 1
1...515253...81Latest