Quality Assurance Projects - Issue Tracker

Tell us what’s happening:
I’ve started working on the issue tracker project and currently im working on the post endpoint. Im abale to pass 1/3 tests; the one where it returns error when one of the required fields are missing but the other 2 tests for returning the object are not passing. I’ve added my api code below:

Your code so far

‘use strict’;
const mongoose = require(“mongoose”);
const IssueModel = require(“…/models”).Issue;
const ProjectModel = require(“…/models”).Project;

module.exports = function (app) {

app.route(‘/api/issues/:project’)

.get(function (req, res){
  let project = req.params.project;
  
})

.post(function (req, res){
  let project = req.params.project;
  
  const issue_title = req.body.issue_title;
  const issue_text = req.body.issue_text;
  const created_by = req.body.created_by;
  const assigned_to = req.body.assigned_to;
  const status_text = req.body.status_text;
  
  if (!issue_title || !issue_title || !created_by){
    res.json({error: 'required field(s) missing'});
  }
  else {
    const newIssue = new IssueModel({
      issue_title: issue_title,
      issue_text: issue_text,
      created_by: created_by,
      asigned_to: assigned_to,
      status_text: status_text,
      created_on: Date(),
      updated_on: Date(),
      open: true,
      _id:_id,
    });
    res.send(newIssue);
  }
  
})

.put(function (req, res){
  let project = req.params.project;
  
})

.delete(function (req, res){
  let project = req.params.project;
  
});

};

looking for some direction on what am i missing/doing wrong. Been stuck on it long enough to ask and googling didnt help much.

thanks in advance!

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36

Challenge: Quality Assurance Projects - Issue Tracker

Link to the challenge:

Please post a Replit or a GitHub repo.

Here’s my replit link: https://boilerplate-project-issuetracker.mmuneeb.repl.co

What is findByName supposed to be? Also, you are calling findOne but not doing anything with it.

Did a lot of searching today and managed to get all my post tests to pass. Im still having trouble with my Get, Put and Delete requests. please advise

Are you not reading the error messages?

ReferenceError: Issue is not defined
at /home/runner/boilerplate-project-issuetracker/routes/api.js:15:7
const IssueModel = require("../models").Issue;

// ...code

Issue.find(filterObject, (error, finddata) => {
// ...code

for some reason I’m not getting the error messages. but even with that change It’s not passing the Get request tests.

It is probably just Replit restarting the server when it crashes (which is super dumb but that is what they do).

You can add the --watch flag to the start script "node --watch server.js" or install nodemon and use it. That should pause the execution after the crash.


You are finding by a property that isn’t in your Schema project which causes it to be ignored and return everything.

If you set the strictQuery option to 'throw' in the IssueSchema creation it should throw an error instead. You have to catch it, or at least log it, inside IssueModel.find to see it.

Model.find()
The strictQuery Option

const IssueSchema = new mongoose.Schema({
  issue_title: { type: String, required: true },
  issue_text: { type: String, required: true },
  created_on: Date,
  updated_on: Date,
  created_by: { type: String, required: true },
  assigned_to: String,
  open: Boolean,
  status_text: String,
}, {
  strictQuery: 'throw'
});
IssueModel.find(filterObject, (error, finddata) => {
  console.log(error) // StrictModeError: Path "project" is not in schema and strictQuery is 'throw'.
//...code 

You have another error that will throw but with the change to the start script you should at least be able to see it now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.