Skip to content
Snippets Groups Projects
Commit 77b4f561 authored by Tormod Nygård's avatar Tormod Nygård
Browse files

Issue: Fix "categoryid" in backend (#4)

parent 200bf5be
No related branches found
No related tags found
No related merge requests found
...@@ -11,18 +11,18 @@ const category = new Category(); ...@@ -11,18 +11,18 @@ const category = new Category();
// Create posts `/api/post/` // Create posts `/api/post/`
//'{"title":"test3","description":"test3","timestamp":123123,"owner":"test3","category":"test3","imageUrl":"test3"}' //'{"title":"test3","description":"test3","timestamp":123123,"owner":"test3","category":"test3","imageUrl":"test3"}'
router.route('/').post(async (request: Request, response: Response) => { router.route('/').post(async (request: Request, response: Response) => {
const {title, description, timestamp, owner, category, imageUrl} = request.body; const {title, description, timestamp, owner, categoryid, imageUrl} = request.body;
try { try {
const post: IPost = { const post: IPost = {
"title": title, "title": title,
"description": description, "description": description,
"timestamp": timestamp, "timestamp": timestamp,
"owner": owner, "owner": owner,
"category": category, "categoryid": categoryid,
"imageUrl": imageUrl "imageUrl": imageUrl
}; };
if (Object.values(post).filter(p => p == undefined).length > 0) return response.status(500).send("Error"); if (Object.values(post).filter(p => p == undefined).length > 0) return response.status(500).send("Error");
const input = (`INSERT INTO post(title, description, timestamp, owner, category, imageUrl) VALUES (?,?,?,?,?,?)`) const input = (`INSERT INTO post(title, description, timestamp, owner, categoryid, imageUrl) VALUES (?,?,?,?,?,?)`)
return response.status(200).json( return response.status(200).json(
await query(input,Object.values(post)) await query(input,Object.values(post))
); );
......
...@@ -4,7 +4,7 @@ interface IPost { ...@@ -4,7 +4,7 @@ interface IPost {
description: string; description: string;
timestamp: number; timestamp: number;
owner: string; owner: string;
category: string; categoryid: number;
imageUrl: string; imageUrl: string;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment