Replies: 1 comment 3 replies
-
Add a updateStudentDataById: builder.mutation({
queryFn: async ( activeStudent ) => {
+ console.log("test")
const studentDoc = { studentName: activeStudent.studentName,
studentLastName: activeStudent.studentLastName }
const { data, error } = await supabase
.from('students')
.update( studentDoc )
.eq('id', activeStudent.id )
return { data, error }
},
invalidatesTags: ["StudentById"]
}), If that logs out, you are probably using Supabase wrong in some way in the following lines, but it has nothing to do with RTK. The only job RTK has is to call that function - if that happens, it's your job to call Supabase correctly. Unfortunately, I can't help you with that part as I'm not familiar with Supabase. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have already configured my project with Supabase and all is working just fine. I am able to do CRUD operations using the thunk procedure from Redux-Toolkit. However, I am learning how to use RTK-Query and its habilities to invalidate Tags so the data is refetched. So I configured my "supabaseApi" with the endpoints and all is working fine.
What I am not achieving is to UPDATE data. I could do it with a thunk, so it is not a RLS policy issue. This is my endpoint for RTK-Query:
And then, I import the function in the component with:
And I assign this constant in an "onClick" for a button:
When I click the button I don't get any error in the console but the data is not updated in Supabase. It is updated in my local state but when I refresh it will turn back to the previous state (not updated in the database).
------------------------- Edited.
I found the issue. It is not related with RTK-Query or Supabase. It was a line that I missing sending to the store the appropriate values. Sorry about that!
Beta Was this translation helpful? Give feedback.
All reactions