Skip to content

Commit

Permalink
fix route to get donations by id
Browse files Browse the repository at this point in the history
  • Loading branch information
jessica2673 committed Apr 3, 2024
1 parent 7f88504 commit eb513a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/typescript/rest/donationsRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ donationRouter.get("/:id", async (req: any, res: any) => {
const id = req.params.id;

try {
const userDonations = donationService.getUserDonation(id);
const userDonations = await donationService.getUserDonation(id);

res.status(200).json(userDonations);
} catch (error) {
Expand Down
25 changes: 13 additions & 12 deletions backend/typescript/services/implementations/donationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ class DonationService implements IDonationService {
}

async getUserDonation(user_id: string): Promise<Array<DonationDTO>> {
try {
const userDonations = await prisma.donation.findMany({
where: {
user_id: user_id,
}
});

return userDonations;
} catch (error) {
Logger.error(`Error fetching donation for user ${user_id} = ${error}`);
throw error;
}
console.log(user_id);
try {
const userDonations = await prisma.donation.findMany({
where: {
user_id: user_id,
}
});

return userDonations;
} catch (error) {
Logger.error(`Error fetching donation for user ${user_id} = ${error}`);
throw error;
}
}

async createDonation(user_id: string, amount: number, cause_id: number, is_recurring: string, confirmation_email_sent: boolean): Promise<DonationDTO> {
Expand Down

0 comments on commit eb513a4

Please sign in to comment.