Create Book Form Code Along, on submit showing "Casting Error"

hello everybody, im trying to code along this project “local book library” but with"ejs" as a “view engine”

so far it’s going alright, but in this tutorial my “on submit” even is showing me “casting error” and as it’s als mentioned there might be a “casting error” and i tried to address that in my “view code” as they suggested author._id.toString()===book.author._id.toString() but im still getting that “Casting Error”

Create Book form - Learn web development | MDN

here is my current attempted code for it:
bookController: Intro-to-node-js/external-resources/assignments/mdn-express/local-library-tutorial/controllers/bookController.js at d00bd0fb2902546e79b26b6f3707f0faf0187783 · bappyasif/Intro-to-node-js · GitHub

viewFile: Intro-to-node-js/external-resources/assignments/mdn-express/local-library-tutorial/views/book_form.ejs at d00bd0fb2902546e79b26b6f3707f0faf0187783 · bappyasif/Intro-to-node-js · GitHub

please help me fix this, any feedback is appreciated, thanks for looking into this, much appreciated :slight_smile:

Can you help me in understanding?

  1. What is the data structure?
  2. Is the data loaded when you are trying to access this?
1 Like

thanks but i managed to solve it already, i should have been here earlier

basically i was looking at a “different” scope for that “error” affecting “code”, classic rookie mistake :grin:

Hi a.b.,

Did you run into a “Casting Error” when setting up the genreContoller.js code for the call back to render the Genre Detail Page?

I’ve run into a Casting Error when using the findById() method using the “req.params.id”.

And i can’t figure out the fix.

Thoughts?