Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
How can I debug to see my database in Mongoose

Please see my question in image. I opened Mongoose, type "nodemon app.js" but cannot run my app.js successfully (it said "SyntaxError: Invalid or unexpected token"). I am not sure whether it's because I didn't finish the code, but I'm supposed to see "Success" in my hyper but not the SyntaxError. Thank you so much! A newbie here~

const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");

const app = express();

app.set('view engine', 'ejs');

app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static("public"));

mongoose.connect("mongodb://localhost:27017/todolistDB", {useNewUrlParser: true});

const itemsSchema = new mongoose.Schema({
  name: String
});
const Item = mongoose.model("Item", itemsSchema);

const item1 = new Item ({
  name: "Drink milk"
});

const item2 = new Item ({
  name: "Eat egg"
});

const defaultItems = [item1, item2];
Item.insertMany(defaultItems, function(err) {
  if (err){
    console.log(err);
  } else {
    console.log("Success");
  }
});

app.get("/", function(req, res) {


  res.render("list", {listTitle: "Today", newListItems: defaultItems});

});

app.post("/", function(req, res){

  const item = req.body.newItem;

  if (req.body.list === "Work") {
    workItems.push(item);
    res.redirect("/work");
  } else {
    items.push(item);
    res.redirect("/");
  }
});


app.listen(3000, function() {
  console.log("Server started on port 3000");
});

My Question

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!