Sorio
Explore posts from serverserror with the supabase module in server side
Hello 👋
Since a few days, I'm learning to create a backend with nuxt (nitro).
I use supabase to store my data.
To train myself I've created a to-do list application with a few apis like addToDo, removeToDo ...
But I have a typescript error in two of my apis.
The one to add a task and the one to switch its value (true false).
here the code of the complete.post.ts :
import { serverSupabaseUser, serverSupabaseClient } from '#supabase/server'
export default defineEventHandler(async (event) => {
const user : any = await serverSupabaseUser(event)
if (!user) {
throw createError({ statusCode: 401, statusMessage: 'Unauthorized' })
}
const client = await serverSupabaseClient(event)
const body = await readBody(event)
const id = body.id
const completed = Boolean(body.done)
console.log(user.id);
const { data } = await client.from('tasks').update({ done: completed }).eq('id', id).select()
return data
})
And the error :
error : Argument of type '{ done: boolean; }' is not assignable to parameter of type 'never'.ts(2345
I hope you'll help me.
Thanks in advance 🤗25 replies