Stupid question but how to I put header inside my ...
# help
i
Stupid question but how to I put header inside my insert method? currently I get insert because I have a policy that only "authorizated people" has access, but I am logged in
n
Hello @InvestorChris! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
i
My login/auth stuff works, but when I try to insert data to my table it does not work, it does work on Postman though. (as I send it in my header in postman)So I guess the issue is that I am not sending my "authorization details" on my insert
Copy code
const { data, error } = await supabase
    .from('Bookings')
    .insert([
      { user_id: user_id,
        day_booked: day_wanted_to_book,
        time_booked: hour_wanted_to_book,
      }])
g
Header is set by Supabase client. You need a signed in user or to provide an exiting access token to it.
n
InvestorChris (2022-04-07)
i
Hm, I am signed in and that works, but once I try to insert a record when logged in, it wont populate the table. instead i get [Unhandled promise rejection: Error: not implemented]
user_id is taken from my session.user.id, so I know i'm logged in as I console.logged that :/.
g
Console.log supabase object there you should see user session and tokens in. Your message is strange. Is a network request even going out?
i
Hmm, not sure how to check that. I'm using the react native expo tutorial and I got all of that working but once I try to setup my own table and try to make it so a user can populate that table, it wont work
It's through Android emulator
From what I've gathered supabase connection should work because I am accessing the session.user.email for example, and I'm able to logout/login with user. I have both removed RLS and put it back with the policy of "Enable insert for authenticated users only"
and I even tried creating a new table and only having id + 1 other column to populate, it's the same issue.
Copy code
const { data, error } = await supabase
    .from('new_bookings')
    .insert([
      
      { time_for_booking: "heello"},
    ])
I have double checked and I can see that I go into the method that has that fetch, and I tried console.logging, and it works until the code above starts, thereafter no more console.logs works.
Copy code
async function sendBookingData(session: any, day: String, time: String) {
    const user_id = session.user.id
    const day_wanted_to_book = day
    const hour_wanted_to_book = time

    console.log("before supabase insert")   // works
    const { data, error } = await supabase
    .from('new_bookings')
    .insert([
      
      { time_for_booking: "heello"},
    ])
      
    console.log("after supabase insert") //does not work
  }
}
example above of whole func ^
and in postman/thunderClient it works
g
I find a few hits googling your error and Supabase react native. Several reference missing polyfills. Really don’t see how a different table can matter especially with RLS off and it working in postman. But I’ve never used react native so really not sure.
i
Hmm i'll check on that, it's super weird how it does not work : /
Solved it! You were right, had to put in import 'react-native-url-polyfill/auto'; in the app.tsx file
Cheers mate, your the best @User
n
Thread was archived by @InvestorChris. Anyone can send a message to unarchive it.