Skip to content

Commit 210760f

Browse files
committed
update readnote handler
1 parent 3c72ab2 commit 210760f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

routes/notes/routes.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@ module.exports = async function noteRoutes(fastify) {
5757
},
5858
},
5959
handler: async function readNote(request, reply) {
60-
const note = await request.notesDataSource.readNote(request.params.id)
61-
if (!note) {
62-
reply.code(404)
63-
return { error: 'Record is not found' }
60+
try {
61+
const note = await this.notesDataSource.readNote(request.params.id)
62+
if (!note) {
63+
reply.code(404)
64+
return { error: 'Note not found' }
65+
}
66+
67+
return { data: note }
68+
} catch (error) {
69+
console.error('Error fetching note details:', error)
70+
reply.code(500)
71+
return { error: 'Internal Server Error' }
6472
}
65-
reply.code(201)
66-
return note
6773
},
6874
})
6975

0 commit comments

Comments
 (0)