Skip to content

Always send a response #47

@oliverjam

Description

@oliverjam

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions