DEV Community

Discussion on: Learning Node.js building a simple Express API - Part II

Collapse
 
bplus profile image
Bryan Nelson • Edited

Hi Filipe,

Nice tutorial! I have two questions/suggestions.

I believe you should have the code for

import bodyParser 

listed as part of app.js, not src/index.js. At least, that's what worked for me.

Also, eslint was throwing an error for me, telling me to use '===' instead of '==' in the various filter/map/indexOf functions. So I used '===' and then changed pulling my IDs from req.params to:
const id = parseInt(req.params.id)

Is there a better way to cast the id constant to an int while still using object destructuring, so I can use strict equality while still keeping the nice format you used?

Collapse
 
filipedomingues profile image
Filipe Domingues • Edited

Thanks for the feedback!
Yes you are right, I wrote src\index.js instead of src\app.js.
About parsing on Object destructuring I don't think it's possible but your solution works great. I didn't focus too much on validations for now since I'm going to come back to the routes when I finish the database module. Anyway you are right, you should use '===' whenever you can.