Hi everyone,
I’m having an issue where the test 7 is failing despite the PUT request working in the code.
solution: https://boilerplate-project-issuetracker.supersyd.repl.co
.put(function (req, res){
console.log(req.url)
let project = req.params.project;
let _id = req.body._id;
let issue_title = req.body.issue_title;
let issue_text = req.body.issue_text;
let created_by = req.body.created_by;
let assigned_to = req.body.assigned_to;
let open = req.body.status_text;
let status_text = req.body.status_text;
console.log(project,_id,issue_title,issue_text,created_by,assigned_to,open,status_text)
const updateFields = {};
if(issue_title){
updateFields.issue_title = issue_title
}
if(issue_text){
updateFields.issue_text = issue_text
}
if(created_by){
updateFields.created_by = created_by
}
if(assigned_to){
updateFields.assigned_to = assigned_to
}
if(status_text){
updateFields.status_text = status_text
}
if(project){
if(_id == undefined || _id == ""){
console.log({
error: 'missing _id'
})
return res.json({
error: 'missing _id'
})
} else {
console.log(updateFields, "UpdateFields")
if(Object.keys(updateFields).length>0){
Issue.findById(_id,(err,dataIssue)=>{
console.log({
dataIssue: dataIssue}, "HEHEHEHEHE")
if(err || dataIssue === null){
console.log({
error: 'could not update',
'_id': _id })
return res.json({
error: 'could not update',
'_id': _id })
} else
if(dataIssue != null){
if(updateFields.issue_title){
dataIssue.issue_title = updateFields.issue_title;
}
if(updateFields.issue_text){
dataIssue.issue_text = updateFields.issue_text;
}
if(updateFields.created_by){
dataIssue.created_by = updateFields.created_by;
}
if(updateFields.assigned_to){
dataIssue.assigned_to = updateFields.assigned_to;
}
if(updateFields.open){
dataIssue.open = updateFields.open;
}
if(updateFields.status_text){
dataIssue.status_text = updateFields.status_text;
}
dataIssue.updated_on = new Date().toISOString();
dataIssue.save((err,issue)=>{
console.log({
issueHEHEHE: issue}, "HEHEHEHEHE")
if(err || issue === null){
console.log({
updatedIssue: issue,
error: 'could not update',
'_id': _id })
return res.json({
error: 'could not update',
'_id': _id })
} else {
console.log({ result: 'successfully updated', '_id': _id })
return res.json({ result: 'successfully updated', '_id': _id })
}
})
}
})
} else {
console.log({
error: 'no update field(s) sent',
'_id': _id })
return res.json({
error: 'no update field(s) sent',
'_id': _id })
}
}
}else {
return res.send('Please enter project name')
}
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36
.
Challenge: Issue Tracker
Link to the challenge: