Issue Tracker Project - Fails FCC delete request test but works for me

Hello there,

When I submit your project, and look in the browser console, I see this error:

Error: expected { error: 'missing_id' } to deeply equal { error: 'missing _id' }

Now, here is the relevant section:

.delete(function (req, res) {
      let project = req.params.project;
      const { _id } = req.body;
      if (!_id) {
        res.json({ error: "missing_id" });
        return;
      }

Also, I notice the functional tests are not passing, because of:

suite("Functional Tests", function() {
  suite("Routing Tests", fuction() {
    suite("3 Post request Tests", function() {
// Line 183
test("Update an issue with missing _id: PUT request to /api/issues/{project}", function (done) {
        chai
        .request(server)
        .put("/api/issues/projects")
        .send({
          _id: "60206803aeb79335a895a37c",
          issue_title: "Update",
          issue_text: "update",
        })
        .end(function (err, res) {
          assert.equal(res.status, 200);
          assert.equal(res.body.error, "missing _id");
          done();
        };
      });
//Line 16
.post("/api/issues/projects")
        set("content-type", "application/json")
        .send({

The syntax highlighting is the hint…

Also, why are you sending objects like this:

if (!projectdata || err) {
          res.send({ error: "could not delete", _id: _id });
        } else {
          const issueData = projectdata.issues.id(_id);
          if (!issueData) {
            res.send({ error: "could not delete", _id: _id });
            return;
          }

Hope this helps

2 Likes