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 trialjay aljoe
4,113 PointsI found that if you replace any char in the qID or aID with another char, the entire server breaks. How to handle that?
in Postman or Browser if you send a Get request to a specific question with qID and you replace any char in the question id with any other char, the server breaks. So, Im sure we can handle that but what is the proper way to do so?
2 Answers
Putra Aryotama
36,050 Pointsyou're not defining, setting status code, and passing the error correctly Check your routes.js file
on lines 10-14 ('qID' param middleware):
if (!question) {
error = new Error("Not Found");
res.status = 404;
return next(err);
}
should be:
if (!question) {
let err = new Error("Not Found");
err.status = 404;
return next(err);
}
same goes for 'aID' param middleware in line on lines 24-28.
Putra Aryotama
36,050 PointsPutra Aryotama
36,050 PointsCan you post your code?