-
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.
created getSurveyByID function and corresponding API endpoint
- Loading branch information
1 parent
8188bd7
commit f0ae499
Showing
2 changed files
with
29 additions
and
1 deletion.
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,18 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { getSurveyByID } from "@/lib/firebase/database/surveys"; | ||
|
||
export async function GET( | ||
req: NextRequest, | ||
{ params }: { params: { surveyId: string } } | ||
) { | ||
const { surveyId } = params; | ||
try { | ||
const survey = await getSurveyByID(surveyId); | ||
return NextResponse.json({ data: survey }, { status: 200 }); | ||
} catch (err) { | ||
return NextResponse.json( | ||
{ error: "error getting survey by id" }, | ||
{ status: 500 } | ||
); | ||
} | ||
} |
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