Skip to content

get tasks , mongoose error , from video number 5 in you tube #9

@MRUTYUNJAYAMOHANTY

Description

@MRUTYUNJAYAMOHANTY

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;
// })
// })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions