From 702e1d8458b3b38fe3913e9a9a2bd0fe397b7354 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Wed, 27 Dec 2023 16:31:43 +0100 Subject: [PATCH] :construction: working on get-endpoint --- backend/cmd/main.go | 2 -- backend/db/get_user_questions.go | 16 +++++++++++----- frontend/src/routes/form/+page.server.ts | 12 ++++++++++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/backend/cmd/main.go b/backend/cmd/main.go index de39ea3..0bedccd 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -39,8 +39,6 @@ func main() { return } - - // Respond with the ID of the newly inserted respondent c.JSON(http.StatusOK, gin.H{"respondentID": respondentId}) }) diff --git a/backend/db/get_user_questions.go b/backend/db/get_user_questions.go index c150c5e..c81d8c5 100644 --- a/backend/db/get_user_questions.go +++ b/backend/db/get_user_questions.go @@ -52,10 +52,16 @@ func GetUserQuestions(respondendID int) ([5]UserQuestions, error) { "LIMIT 5", respondendID) - stmt, err := db.Prepare(getQuestionsStatement) - if err != nil { - log.Fatalf("Error preparing statement: %v\n", err) - } - defer stmt.Close() + stmt, err := db.Prepare(getQuestionsStatement) + if err != nil { + log.Fatalf("Error preparing statement: %v\n", err) + } + defer stmt.Close() + + var questions [5]FormQuestion + + rows, err := stmt.Query(getQuestionsStatement) + + } \ No newline at end of file diff --git a/frontend/src/routes/form/+page.server.ts b/frontend/src/routes/form/+page.server.ts index e69de29..d90d75a 100644 --- a/frontend/src/routes/form/+page.server.ts +++ b/frontend/src/routes/form/+page.server.ts @@ -0,0 +1,12 @@ +import { error } from '@sveltejs/kit'; + +/** @type {import('./$types').PageServerLoad} */ +export async function load({ params }) { + const post = await getPostFromDatabase(params.slug); + + if (post) { + return post; + } + + error(404, 'Not found'); +} \ No newline at end of file