diff --git a/src/library/library-routes.ts b/src/library/library-routes.ts index 89d080e..544e5de 100644 --- a/src/library/library-routes.ts +++ b/src/library/library-routes.ts @@ -23,14 +23,14 @@ libraryRoutes.get('/all/', jwtAuthentication, async (request, response) => { libraryRoutes.get('/search/', jwtAuthentication, async (request, response) => { const wordCollection = getDatabaseClient().db(DB_NAME).collection('words'); - if (!request.body.name) { + if (!request.query.name) { response.status(400); response.send("Fill in the word to search for"); return; } const allWords = await wordCollection.find({ - name: {'$regex':'^' + request.body.name.toString().toUpperCase() + '*'} + name: {'$regex':'^' + request.query.name.toString().toUpperCase() + '*'} }).toArray(); response.status(200); diff --git a/src/user-profile/category-routes.ts b/src/user-profile/category-routes.ts index 9c6d98b..f74c7b7 100644 --- a/src/user-profile/category-routes.ts +++ b/src/user-profile/category-routes.ts @@ -14,8 +14,15 @@ export const jwtAuthentication = passport.authenticate('jwt', { session: false } categoryRoutes.get('/details/', jwtAuthentication, async (request, response) => { const categoryCollection = getDatabaseClient().db(DB_NAME).collection('categories'); + + if (!request.query._id) { + response.status(400); + response.send("Missing category _id"); + return; + } + const currentCategory = await categoryCollection.findOne({ - _id: new ObjectId(request.body._id), + _id: new ObjectId(request.query._id.toString()), }); if (currentCategory) { diff --git a/src/user-profile/shelf-routes.ts b/src/user-profile/shelf-routes.ts index 3246d86..d6d29d6 100644 --- a/src/user-profile/shelf-routes.ts +++ b/src/user-profile/shelf-routes.ts @@ -17,7 +17,7 @@ shelfRoutes.get('/details/', jwtAuthentication, async (request, response) => { const shelfCollection = getDatabaseClient().db(DB_NAME).collection('shelves'); const currentShelf = await shelfCollection.findOne({ - _id: new ObjectId(request.body._id) + _id: new ObjectId(request.query._id.toString()) }); if (!currentShelf) {