UNLV-CS472-672 / 2024-S-GROUP5-Munch

The Munch app is a social platform where users create profiles by selecting preferred foods.
1 stars 11 forks source link

Create route to toggle bookmark #77

Closed tadakane closed 6 months ago

tadakane commented 6 months ago

Description / Changes Made

-Created bookmark routes for our server. It's one patch method that toggles bookmark depending on if the bookmark is already added for the user or not -Takes in user_id in the route, post or recipe id in the request json

Portions of this code that utilized AI generation

None

How to Test

  1. Using Postman, use endpoint api/users//bookmarks
  2. In the body tab, select raw and input JSON information. Regardless of if you are bookmarking a post or recipe, use format {"post": "post or recipe id"}. You must have "post" as field or it won't work. The post or recipe id must be an actual post or recipe in the database in the form of "posts/" or "recipes/. (I'm open to change this input format if it's easier another way)
  3. Set postman to a PATCH method and send request.
  4. If the bookmark is already in the users "bookmarks" field, it will be removed. If it's not in the "bookmarks" field, it will be added. Both are done with the PATCH method.

Unit Tests currently in development

Checklist