-
Notifications
You must be signed in to change notification settings - Fork 142
Description
need help for , Cast to ObjectId failed for value "undefined" (type string) at path "_listId" for model "Task"
Same issue on stackoverflow , asked by some one ,
https://stackoverflow.com/questions/64395484/mongoose-casterror-cast-to-objectid-failed-for-value-listid-at-path-listid
need to show tasks , in task.co.ts ; this.route.params.subscribe((params:Params)=>{
this.taskService.getTasks(params['listId']).subscribe((tasks:any)=>{
this.tasks = tasks;
})
})
In task.service.ts ; getTasks(listId: string) {
return this.webReqService.get(lists/${listId}/tasks);
}
task model ; 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 }
the issue lines
// this.route.params.subscribe((params:Params)=>{
// this.taskService.getTasks(params['listId']).subscribe((tasks:any)=>{
// this.tasks = tasks;
// })
// })