I am on my 5th iternation of this and cant seem to pass the success test. Using the tester on the app as well as checking in the database, everything seems to work.
I even have been following along youtube videos to check my work and i cant seem to see my errors.
.put(function(req, res) {
let project = req.params.project;
const {
_id,
issue_title,
issue_text,
created_by,
assigned_to,
status_text,
open,
} = req.body;
if (!_id) {
res.json({ error: "missing _id" });
return;
}
if (
!issue_title &&
!issue_text &&
!created_by &&
!assigned_to &&
!status_text &&
!open
) {
res.json({ error: "no update field(s) sent", _id: _id });
return;
}
Project.findOne({ name: project }, (err, projectdata) => {
if (err || !projectdata) {
res.json({ error: "could not update", _id: _id });
} else {
const issueData = projectdata.issues.id(_id);
if (!issueData) {
res.json({ error: "could not update", _id: _id });
return;
}
issueData.issue_title = issue_title || issueData.issue_title;
issueData.issue_text = issue_text || issueData.issue_text;
issueData.created_by = created_by || issueData.created_by;
issueData.assigned_to = assigned_to || issueData.assigned_to;
issueData.status_text = status_text || issueData.status_text;
issueData.updated_on = new Date();
issueData.open = open;
projectdata.save((err, data) => {
if (err || !data) {
res.json({ error: "could not update", _id: _id });
} else {
res.json({ result: "successfully updated", _id: _id });
}
});
}
});
})
I am passing all other tests, except the actual testing tests, so i would assume i am importing everything correct and it is a coding error somewhere