diff --git a/server/src/controllers/postcontroller/index.ts b/server/src/controllers/postcontroller/index.ts index c437f2c608dd9d3087ecc1099a3544a4585f5a7b..231d20114cca10c6e01b669b1c515afc82b53b24 100644 --- a/server/src/controllers/postcontroller/index.ts +++ b/server/src/controllers/postcontroller/index.ts @@ -11,18 +11,18 @@ const category = new Category(); // Create posts `/api/post/` //'{"title":"test3","description":"test3","timestamp":123123,"owner":"test3","category":"test3","imageUrl":"test3"}' 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 { const post: IPost = { "title": title, "description": description, "timestamp": timestamp, "owner": owner, - "category": category, + "categoryid": categoryid, "imageUrl": imageUrl }; 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( await query(input,Object.values(post)) ); diff --git a/server/src/models/post.ts b/server/src/models/post.ts index 146bf71067332d191d975514b24837200d3d3706..4ada588ab6f3511356f96dcf381c2db1a1ed896f 100644 --- a/server/src/models/post.ts +++ b/server/src/models/post.ts @@ -4,7 +4,7 @@ interface IPost { description: string; timestamp: number; owner: string; - category: string; + categoryid: number; imageUrl: string; }