Skip to content

Commit

Permalink
update readnote handler
Browse files Browse the repository at this point in the history
  • Loading branch information
tryb3l committed Aug 28, 2024
1 parent 3c72ab2 commit 210760f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions routes/notes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ module.exports = async function noteRoutes(fastify) {
},
},
handler: async function readNote(request, reply) {
const note = await request.notesDataSource.readNote(request.params.id)
if (!note) {
reply.code(404)
return { error: 'Record is not found' }
try {
const note = await this.notesDataSource.readNote(request.params.id)
if (!note) {
reply.code(404)
return { error: 'Note not found' }
}

return { data: note }
} catch (error) {
console.error('Error fetching note details:', error)
reply.code(500)
return { error: 'Internal Server Error' }
}
reply.code(201)
return note
},
})

Expand Down

0 comments on commit 210760f

Please sign in to comment.