Personal Library - Undefined id in last 2 routes

Tell us what’s happening:

Hi everyone,

I’m having an issue with the Personal Library project and really can’t understand where it comes from.

Everything works fine except for the last 2 routes: app.route(‘/api/books/:id’).post and app.route(‘/api/books/:id’).delete.
If i console.log(req.params.id), it returns undefined and crashes. Yet, if I use the app.route(‘/api/books/:id’).post route from the Test post to /api/books/{bookid} form above, it works perfectly (except that I still have to implement the commentcount increment).

I have no clue why id is returning undefined when using the Add Comment and Delete Book buttons from the Sample Front End form…

Any idea ?

Thanks a lot !

Your project link(s)

solution: boilerplate-project-library - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36

Challenge Information:

Quality Assurance Projects - Personal Library

Damn, I spent hours looking for a solution and of course I found it minutes after opening this thread…

Issue was that in my get route, I was returning a book object with an id property, instead of _id, and changing this somehow solved the problem !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.