-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Harshal Ranjhani
authored and
Harshal Ranjhani
committed
Apr 23, 2024
1 parent
db0eb05
commit 03300e8
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// api route to get user details | ||
|
||
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs' | ||
import { cookies } from 'next/headers' | ||
|
||
export async function POST(request: Request) { | ||
const cookieStore = cookies() | ||
const supabase = createRouteHandlerClient({ | ||
cookies: () => cookieStore | ||
}) | ||
|
||
const body = await request.json() | ||
const { user_id, question_id } = body | ||
|
||
// delete the question from the questions table where the question_id field matches the question_id passed in the request and the user field matches the user_id passed in the request | ||
const { data } = await supabase | ||
.from('questions') | ||
.delete() | ||
.match({ id: question_id, user: user_id }) | ||
.throwOnError() | ||
|
||
return new Response(JSON.stringify(data), { status: 200 }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters