From 0700c73a1245e7f670f3dc8df88de18bbb8880a6 Mon Sep 17 00:00:00 2001 From: Alan Chamathil <77508072+AlanChamathil@users.noreply.github.com> Date: Mon, 27 Mar 2023 11:41:51 +0100 Subject: [PATCH] v2 with retriving notifications --- src/routes/notification.js | 12 ++++++++---- src/schema/schema.js | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/routes/notification.js b/src/routes/notification.js index 7ddc61a..2c0849e 100644 --- a/src/routes/notification.js +++ b/src/routes/notification.js @@ -16,14 +16,18 @@ const Notification = require('../schema/schema') router.get("/info/:id",(req,res) =>{ - res.send("id") // grab the userid - const user_id =req.params.id; - // retrieve all the notifcations stored in the database - + Notification.findById(req.params.id).then((notifiaction) => { + if(!notifiaction){ + return res.status(404).send(); + } + res.send(notifiaction); + }).catch((error) => { + res.status(500).send(error); + }) // send the notifications to the notification page diff --git a/src/schema/schema.js b/src/schema/schema.js index 5031912..9c3ed30 100644 --- a/src/schema/schema.js +++ b/src/schema/schema.js @@ -1,6 +1,7 @@ const mongoose = require('mongoose'); const notificationSchema = new mongoose.Schema({ + userid:Number, title: String, description: String, date: Date -- GitLab