Skip to content
Snippets Groups Projects
Commit ac88b367 authored by alec.schmidt's avatar alec.schmidt
Browse files

fixed GET questions

parent ce0d2afc
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -113,7 +113,7 @@ class DBHandler { ...@@ -113,7 +113,7 @@ class DBHandler {
await asyncdb.all(insert_question); await asyncdb.all(insert_question);
const id_json = await asyncdb.get(get_id) const id_json = await asyncdb.get(get_id);
const id_obj = id_json as Question_t; const id_obj = id_json as Question_t;
const insert_correct = "INSERT INTO answer (text_answer, id_question, correct) \ const insert_correct = "INSERT INTO answer (text_answer, id_question, correct) \
...@@ -132,9 +132,19 @@ class DBHandler { ...@@ -132,9 +132,19 @@ class DBHandler {
} }
async getQuestions(req:express.Request, res:express.Response) { async getQuestions(req:express.Request, res:express.Response) {
asyncdb.all("SELECT * FROM questions") const query = "SELECT * FROM questions";
.then( result => res.status(StatusCodes.OK).json(result).end()) const query_answers = "SELECT * FROM answer";
.catch(e => console.log(e))
let questions = await asyncdb.all(query);
let ans = await asyncdb.all(query_answers);
let payload = {
QUESTIONS: questions,
ANSWERS: ans
}
res.status(StatusCodes.OK).json(payload)
} }
async updateQuestion(req:express.Request, res:express.Response){ async updateQuestion(req:express.Request, res:express.Response){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment