|
function get(request, response) { |
|
const catId = request.params.catid; |
|
console.log("catId", catId); |
|
const cat = model.getCat(catId).then((cat) => { |
|
response.send(cat.picture); |
|
}).catch((error) => { |
|
console.error(error); |
|
}) |
Remember your route handlers always need to send a response, especially when errors occur. Here if you don't find a matching cat you just log the error and then stop. This causes the server to eventually time out if the user visits a nonexistent cat page (like /cats/999).
week7-jess/src/handler/catPic.js
Lines 3 to 10 in b9f47e9
Remember your route handlers always need to send a response, especially when errors occur. Here if you don't find a matching cat you just log the error and then stop. This causes the server to eventually time out if the user visits a nonexistent cat page (like
/cats/999).