updates to friend route, some changes to ui components, front end api tools

This commit is contained in:
Mikayla Dobson
2022-12-01 21:52:54 -06:00
parent 8a7eaa7db6
commit 2e48231dc5
10 changed files with 152 additions and 19 deletions

View File

@@ -23,10 +23,16 @@ export const friendRouter = (app: Express) => {
// get all friendships for a user
router.get('/', async (req, res, next) => {
const { user }: any = req.user;
const { pending } = req.query;
try {
const result = await UserInstance.getFriends(user.id);
res.status(200).send(result);
if (pending) {
const result = await UserInstance.getPendingFriendRequests(user.id);
res.status(200).send(result);
} else {
const result = await UserInstance.getFriends(user.id);
res.status(200).send(result);
}
} catch(e) {
next(e);
}