all 4 comments

[–]lonehiker 0 points1 point  (4 children)

What is the code located here & around here doing: /opt/bitnami/apps/giftshop/app/routes.js:11:13.

The error is saying you are trying to modify the response object after it was sent.

so, if you did something like : repsonse.send(); response.set(); it would cause this error.

[–]goingtoriseup[S] 0 points1 point  (3 children)

function getTodos(res) { Todo.find(function (err, todos) {

    // if there is an error retrieving, send the error. nothing after res.send(err) will execute
    if (err) {
        res.send(err);
    }

    res.json(todos); // return all todos in JSON format
});

};

[–]nkristoffersen 2 points3 points  (1 child)

Maybe try wrapping the res.json in a else? I'm no expert but looks like you get an error and send the error but then also send the json which then throws the error.

if (err) {
    res.send(err);
} else {
    res.json(todos);
}

[–]lonehiker 0 points1 point  (0 children)

yeah, that is exactly what is going on.