Issue Tracker Project

Issue Tracker Project


Hello there! I’m working on this project by freeCodeCamp and I’m trying to assign a value from a collection in a database to a variable. The JSON object in the data has a field called issue_title. I am trying to assign that value to a variable if an input field is empty.

The code snippet is as shown below:

let issueTitle = req.body.issue_title !== ‘’? req.body.issue_title : user.findOne({_id:_id}, (err, data) => {
if(err) console.log(err);
return data.issue_title

When I console.log the data.issue_title, I get the value that I’m looking for. However, when I assign the value to the variable ‘issueTitle’ and I console.log the variable, I get a very weird output in console.

Query {

_mongooseOptions: {},
_transforms: [],
NativeCollection {
collection: Collection { s: [Object] },
… it goes on for quite a few lines

Am I doing something wrong? Help would be greatly appreciated :slight_smile:


Anyone? :rofl::rofl::joy: