🚧 working on get-endpoint
This commit is contained in:
		
							parent
							
								
									43be8ac33e
								
							
						
					
					
						commit
						702e1d8458
					
				
					 3 changed files with 23 additions and 7 deletions
				
			
		|  | @ -39,8 +39,6 @@ func main() { | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         // Respond with the ID of the newly inserted respondent |         // Respond with the ID of the newly inserted respondent | ||||||
| 		c.JSON(http.StatusOK, gin.H{"respondentID": respondentId}) | 		c.JSON(http.StatusOK, gin.H{"respondentID": respondentId}) | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|  | @ -52,10 +52,16 @@ func GetUserQuestions(respondendID int) ([5]UserQuestions, error) { | ||||||
| 		"LIMIT 5",  | 		"LIMIT 5",  | ||||||
| 		respondendID) | 		respondendID) | ||||||
| 
 | 
 | ||||||
| 		stmt, err := db.Prepare(getQuestionsStatement) | 	stmt, err := db.Prepare(getQuestionsStatement) | ||||||
| 		if err != nil { | 	if err != nil { | ||||||
| 			log.Fatalf("Error preparing statement: %v\n", err) | 		log.Fatalf("Error preparing statement: %v\n", err) | ||||||
| 		} | 	} | ||||||
| 		defer stmt.Close() | 	defer stmt.Close() | ||||||
|  | 
 | ||||||
|  | 	var questions [5]FormQuestion | ||||||
|  | 
 | ||||||
|  | 	rows, err := stmt.Query(getQuestionsStatement) | ||||||
|  | 
 | ||||||
|  | 	 | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -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'); | ||||||
|  | } | ||||||
		Reference in a new issue
	
	 haraldnilsen
						haraldnilsen