1

I'm working on a project to recreate this: https://issue-tracker.freecodecamp.rocks/

I'm working my way through the test and currently I've just written the Post endpoint to take in user data from the form. the data is to be saved and also displayed back to the user as an object. When I log the attributes to console I can see that the data I input is there however upon clicking the submit button it doesn't display the object.

Link to my code is here: https://replit.com/@Mmuneeb/boilerplate-project-issuetracker?s=app

Here is my api.js code:

"use strict";
const mongoose = require("mongoose");
const IssueModel = require("../models").Issue;
const ProjectModel = require("../models").Project;
const ObjectId = mongoose.Types.ObjectId;

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.json(newIssue);
      }
      
    })
    
    .put(function (req, res){
      let project = req.params.project;
      
    })
    
    .delete(function (req, res){
      let project = req.params.project;
      
    });
    
};

I've tried Googling and watching videos on YouTube but so far to no avail. Please any help as to what I'm doing wrong or missing would be appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
NoobCodes
  • 11
  • 3
  • Can you share the code where your logging it specifically here? and are you getting any errors on the backend or any specific response? – Lucas Hendren Aug 04 '23 at 02:33
  • Im not getting any errors in the console. Here is the replit link for the code:https://replit.com/@Mmuneeb/boilerplate-project-issuetracker?s=app – NoobCodes Aug 04 '23 at 03:11
  • So to clarify, its way better(and youll get better answers) if you put the specific code that is having issues in you question. The link is helpful but its the entire project. My guess would be that your issues are on issue.html around line 49, but its burning time for me to have to read through and find it and on top of that Im not even positive thats the right spot and cant give you a right answer. The link is useful to share, but you should still put the relevant lines of code in your question – Lucas Hendren Aug 04 '23 at 04:20
  • I have put the relevant lines from api.js in the code. html files were provided as part of the project so i dont think the issue would be there. – NoobCodes Aug 04 '23 at 11:36

0 Answers0