hola, soy nuevo en Express y mongoDB, estoy creando una aplicación de administrador de tareas y estoy atascado en un error, cuando ejecuto nodemon app.js tengo este error en la terminal y el error parece provenir del método de publicación ,Puedes ayudarme por favor
El mensaje:
ValidationError: List validation failed: title: Path `title` is required. at model.Document.invalidate (C:\Users\Ned\Workspace\task-manager\api\node_modules\mongoose\lib\document.js:2943:32) at C:\Users\Ned\Workspace\task-manager\api\node_modules\mongoose\lib\document.js:2734:17 at C:\Users\Ned\Workspace\task-manager\api\node_modules\mongoose\lib\schematype.js:1325:9
Aquí está mi:
const mongoose = require('mongoose'); const ListSchema = new mongoose.Schema({ title: { type: String, required: true, minlength: 1, trim: true } }) const List = mongoose.model('List', ListSchema); module.exports = { List } const mongoose = require('mongoose'); const TaskSchema = new mongoose.Schema({ title: { type: String, required: true, minlength: 1, trim: true }, _listId: { type: mongoose.Types.ObjectId, required: true } }) const Task = mongoose.model('Task', TaskSchema); module.exports = { Task } const express = require('express'); const app = express(); const {mongoose} = require('./db/mongoose') const bodyParser = require('body-parser'); // Load in the mogoose models const { List, Task } = require('./db/models'); // Load middleware app.use(bodyParser.json()); // ROUTES HANDLERS // LIST ROUTES /** * GET /lists * Pupose: Get all lists */ app.get('/lists', (req, res) => { // Return an array of all lists in the database List.find({}).then((lists) => { res.send(lists); }) }); /** * POST /lists * Purpose: Create a list */ app.post('/lists', (req, res) => { // Create a new list and return the new list document back to the new user (which includes the id) // The list information (fields) will be passed via the JSON request body let title = req.body.title; let newList = new List({ title }); newList.save().then((listDoc) => { // The full list document is returned (incl. id) res.send(listDoc); }) }); app.listen(3000, () => { console.log('Server in listening on port 3000'); })el error parece provenir del método de publicación cuando intento crear una nueva lista. ayuda por favor ^^