The GET /api/notes/:id and DELETE /api/notes/:id endpoints are not functioning as expected. The endpoints should return or delete the note corresponding to the given ID, but they currently do not. This issue is caused by the req.params.id being a string, while the id in the notes array is a number. As a result, the find and findIndex methods fail to match the note.
Steps to Reproduce:
Start the server using node server.js.
Navigate to http://localhost:3000/api/notes/1 or use a tool like curl or Postman to make a GET request. Observe that the endpoint does not return the expected note. Make a DELETE request to http://localhost:3000/api/notes/1. Observe that the note is not deleted.
Solution:
Convert req.params.id to a number before using it to find or delete the note.
The GET /api/notes/:id and DELETE /api/notes/:id endpoints are not functioning as expected. The endpoints should return or delete the note corresponding to the given ID, but they currently do not. This issue is caused by the req.params.id being a string, while the id in the notes array is a number. As a result, the find and findIndex methods fail to match the note.
Steps to Reproduce: Start the server using node server.js. Navigate to http://localhost:3000/api/notes/1 or use a tool like curl or Postman to make a GET request. Observe that the endpoint does not return the expected note. Make a DELETE request to http://localhost:3000/api/notes/1. Observe that the note is not deleted.
Solution: Convert req.params.id to a number before using it to find or delete the note.
Ref: https://prnt.sc/ohggpLOupB_H