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

    Chris_Acrobat

    04/03/2022, 5:48 PM
    I'm confused. When I call my Edge Function with curl from CLI I get a working and valid 200 response, but when I call it with fetch I get an error. > SyntaxError: Unexpected end of JSON input at JSON.parse () at Server. (file:///src/main.ts:207:45) at async Server.#respond (file:///src/main.ts:111:24) According to my testing, it looks like the body is not imported correctly, but I don't see how that can be the case. For troubleshooting I am logging
    Copy code
    JavaScript
    console.log((await req.text()).length)
    And from curl I get a valid number, but from fetch I get 0. Can anyone see/say what I am doing wrong in my fetch request?
    Copy code
    JavaScript
    fetch(new Request('https://_exeample_.functions.supabase.co/login'), {
        method: 'POST',
        headers: new Headers({
            'Content-Type': 'application/json',
            'Authorization': 'Bearer anon-key-from-https://app.supabase.io/project/_exeample_'
        }),
        body: JSON.stringify({
            a: "A",
            b: "B"
        })
    })
    g
    • 2
    • 23
  • p

    Pete | grid0.xyz

    04/04/2022, 12:10 AM
    I'm new to supabase so this might be something really basic, but I've spent a bunch of time and can't figure it out. I've setup email/password login. On signUp, I setup a sync so that a row is created in the "profiles" table. After creation of the user, I am trying to update the profiles table with the additional info data 'username' and 'fullName'. But I can't seem to update the table
    s
    c
    • 3
    • 23
  • p

    Pete | grid0.xyz

    04/04/2022, 12:10 AM
    Copy code
    const { user, session, error:signUpError } = await supabase.auth.signUp({
                                email: formData.email,
                                password: formData.password,
                            })
                            if (signUpError) {
                                throw signUpError
                            }
    
                            const { data, error } = await supabase
                                .from('profiles')
                                .update({ username: formData.userName })
                                .eq('id', user.id)
  • s

    silentworks

    04/04/2022, 12:20 AM
    Update profile table after signUp
  • z

    zavbala

    04/04/2022, 6:23 PM
    Is there a way to only accept auth from users that before I have invited?
  • s

    silas

    04/04/2022, 8:51 PM
    How do I await supabase.auth.user() or supabase.auth.session() inside an async function? The async function runs immediately on page load, but supabase.auth.user() returns null since it hasn’t retrieved the user object yet.
    p
    g
    • 3
    • 14
  • p

    Pete | grid0.xyz

    04/04/2022, 10:04 PM
    Copy code
    const { user, error } = await supabase.auth.update({email: 'new@email.com'})
    I have a profile page, where users can update their profile info. I'm able to update the data in the public 'profiles' table, but when I try to update the email for the auth table, nothing happens.
    g
    • 2
    • 7
  • g

    garyaustin

    04/04/2022, 10:28 PM
    update auth.user.email
  • z

    Zenon

    04/06/2022, 6:23 PM
    Hey Guys I'm looking to add a search functionality in my application, I want to basically query a db table and want the query to look through different columns for a match. Is there a way I can do that with the client library?
    g
    • 2
    • 4
  • z

    Zenon

    04/06/2022, 6:24 PM
    @User
  • o

    Olyno

    04/06/2022, 6:28 PM
    Hi Please wait a little more before mentioning the support role. You just asked 5 minutes ago :/
  • g

    garyaustin

    04/06/2022, 7:24 PM
    Column matches
  • e

    eMeRiKa

    04/07/2022, 10:58 AM
    I would like to use the postgresql function
    to_timestamp(xxxx)
    What is the best way to do that? It doesn't seem to work with
    Copy code
    const { data, error } = await supabase.from("posts")
          .select('*')
          .gt('to_timestamp(date_start, \'YYYY-MM-DD\')', dateStart.getTime())
          .lt('to_timestamp(date_end, \'YYYY-MM-DD\')', dateEnd.getTime());
  • f

    fernandolguevara

    04/07/2022, 11:31 AM
    @eMeRiKa u need to specify the column u want to filter
  • f

    fernandolguevara

    04/07/2022, 11:32 AM
    Copy code
    js
    const { data, error } = await supabase
      .from('users')
      .select(`
        id, name,
        address->street
      `)
      .eq('address->postcode', 90210)
  • f

    fernandolguevara

    04/07/2022, 11:35 AM
    @eMeRiKa to send the date as string u have
    new Date('XXXXX').toISOString()
    on javascript
  • e

    eMeRiKa

    04/07/2022, 1:06 PM
    my columns are date_start and date_end, I just want to wrap them with a postgresql function
  • e

    eMeRiKa

    04/07/2022, 1:07 PM
    to create a query like:
    SELECT * FROM posts WHERE to_timestamp(date_start, 'YYYY-MM-DD') > NOW() AND to_timestamp(date_end, 'YYYY-MM-DD') < XXXX
  • e

    eMeRiKa

    04/07/2022, 1:09 PM
    yeah but I can't use the filters https://supabase.com/docs/reference/dart/lt and https://supabase.com/docs/reference/dart/gt if it's in string?
  • e

    eMeRiKa

    04/07/2022, 1:47 PM
    It works with a string, thanks!
    Copy code
    const { data, error } = await supabase.from("posts")
          .select('*')
          .gte('date_start', dateStart.toISOString())
          .lte('date_end', dateEnd.toISOString())
  • f

    fernandolguevara

    04/07/2022, 1:59 PM
    https://giphy.com/gifs/the-simple-enjoying-hbB8efOHAezRK
  • f

    fernandolguevara

    04/07/2022, 1:59 PM
    @eMeRiKa nice!
  • h

    honkstyle

    04/07/2022, 4:55 PM
    Probably a basic question since I'm new to to frontend dev and not supabase specific, I'm using react router with a
    <RequireAuth>
    (navigates to
    /login
    if not logged in) component for my routes. My goal is that when a user logs out, they get sent to
    "/"
    . What actually happens is user is first navigated to
    /login
    and then to
    /
    .
    • 1
    • 2
  • y

    Yeehawlerz101

    04/07/2022, 5:11 PM
    Okay guys I'm looking for a bit of help here with how to do this properly with images and "post images"
    g
    • 2
    • 10
  • a

    Abnormal

    04/07/2022, 7:39 PM
    Howdy y'all, Im using Supabase JS and was wondering if there is a way to query for last 30 rows?
  • m

    Muezz

    04/07/2022, 7:41 PM
    Dont use JS but I think you just need to order your query by a column called
    created_at
    (you obviously need to have that column) and then limit the query result.
  • m

    Muezz

    04/07/2022, 7:41 PM
    You dont need to enter the time and date in that column manually every time. Supabase will do that for you automatically.
  • m

    Muezz

    04/07/2022, 7:42 PM
    You just have to have
    now()
    as default value
  • a

    Abnormal

    04/07/2022, 7:43 PM
    Yeah I do have a column like that, along with a ID column to double make sure
  • a

    Abnormal

    04/07/2022, 7:43 PM
    I think you gave me an idea though!
1...555657...81Latest