Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCory Aston
6,058 PointsI'm getting the error Article.findbyPK is not a function when I try to go to localhost:3000/articles/1.
I'm pretty sure that I've done exactly the steps that the instructor had listed up to this point and yet the code is failing when it tries to use the route.
router.get("/:id", asyncHandler(async (req, res) => { const article = await Article.findbyPK(req.params.id); res.render("articles/show", { article, title: article.title }); }));
Help???
2 Answers
Guil Hernandez
Treehouse TeacherHi there, Cory Aston. It looks like the "k" needs to be lowercase: Article.findByPk()
.
Hope this helps. :)
Cory Aston
6,058 PointsOMG - thanks Guil - Literally smacking my head against the desk here trying to figure that one out. Sheesh!
Thanks again!!
Cory Aston
6,058 PointsCory Aston
6,058 PointsI realized I had missed an uppercase in the function call - but I'm still getting the same result...
router.get("/:id", asyncHandler(async (req, res) => { const article = await Article.findByPK(req.params.id) res.render("articles/show", { article, title: article.title }); }));
Article.findByPK is not a function TypeError: Article.findByPK is not a function at C:\Users\corya\Documents\Treehouse\sqlize-with-express\routes\articles.js:40:33