mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-21 12:10:17 -04:00
fix sending promise through json
This commit is contained in:
parent
9622ede6e0
commit
fa4c931742
13
src/api.ts
13
src/api.ts
|
@ -15,7 +15,6 @@ router.get('/user', async (req, res) => {
|
|||
}
|
||||
|
||||
let userID = req.query.userID;
|
||||
console.log(req.session, userID);
|
||||
if (userID === '@me') {
|
||||
userID = req.session.accountID;
|
||||
}
|
||||
|
@ -127,10 +126,14 @@ router.post('/group', (req, res) => {
|
|||
// }
|
||||
});
|
||||
|
||||
router.get('/my_pools', (req, res) => {
|
||||
let groupsWithUser = getPoolsWithUser(req.session.accountID);
|
||||
if (groupsWithUser) {
|
||||
res.json({ status: 'success', data: groupsWithUser });
|
||||
router.get('/my_pools', async (req, res) => {
|
||||
if (req.session.accountID == null) {
|
||||
res.status(401);
|
||||
return res.json({ status: 'error', error: 'need_login' });
|
||||
}
|
||||
let pools = await getPoolsWithUser(req.session.accountID);
|
||||
if (pools) {
|
||||
res.json({ status: 'success', data: pools });
|
||||
} else {
|
||||
res.json({ status: 'error', error: 'not_found' });
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ export function createSession(accountID: string): string {
|
|||
}
|
||||
|
||||
export function getSessionByToken(token: string): SessionData {
|
||||
console.log(sessions);
|
||||
if (token in sessions) {
|
||||
return sessions[token];
|
||||
} else {
|
||||
|
|
|
@ -15,8 +15,10 @@ export function getGroupsWithUser(userID: string) {
|
|||
* @param userID The userID to find
|
||||
* @returns The post IDs with that userID as the author
|
||||
*/
|
||||
export function getPoolsWithUser(userID: string) {
|
||||
return undefined;
|
||||
export async function getPoolsWithUser(userID: string) {
|
||||
return await PoolModel.find({
|
||||
participant_ids: { $all: [userID] },
|
||||
}).exec();
|
||||
}
|
||||
|
||||
export async function getUserByID(userID: string) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user