The get request is not working and when i tried to send it shows me "Cannot read property 'includes ' of undefined"

I am working on the feature to save a post created by another user in the current user profile, but every time I send the request from postman it shows me this error. When I tried to implement another method like map(), It again show me the same error but this time the property is “map”.I don’t know where I am going wrong. Maybe this error is from DOM of javascript (maybe I am wrong.).So I am providing the code below with mongoose models.

router.get('/toggleSave/:id',auth,async (req,res)=>{
    
try{
const post = await Post.findById(req.params.id);
  if (!post) {
    return res.status(404).json('Post not found')
  }

  const { user } = req;

  if (user.savedPosts.includes(req.params.id)) {
    console.log("removing saved post");
    await Profile.findByIdAndUpdate(user.id, {
      $pull: { savedPosts: req.params.id },
    })
  } else {
    console.log("saving post");
    await Profile.findByIdAndUpdate(user.id, {
      $push: { savedPosts: req.params.id },
    });
  }

 res.json(post);
});
}catch(err){
 console.error(err.message);
        res.status(500).send('Server Error')
}


User model

const mongoose=require("mongoose");
const UserSchema=new mongoose.Schema({
    name:{
        type:String,
        required:true
    }
   
,
email:{
    type:String,
    required:true,
    unique:true

},
password:{
    type:String,
    required:true,
    select:true
},
avatar:{
    type:String

},
followers:[{
    type:mongoose.Schema.ObjectId,
    ref:'User'
}],

savedPosts: [{ type: mongoose.Schema.ObjectId, ref: "Post" }],

savedJobs: [{ type: mongoose.Schema.ObjectId, ref: "Job" }],

followersCount:{
type:Number,
default:0,
},

followingCount:{
    type:Number,
    default:0
},

following:[
{
    type:mongoose.Schema.ObjectId,
    ref:'User'
}
],






date:{
    type:Date,
    default:Date.now
},
confirmationToken:{
    type:String
}


});

module.exports=User=mongoose.model("User",UserSchema);

Post model

const mongoose=require('mongoose');
const Schema=mongoose.Schema;
const PostSchema=new Schema({
user:{
    type:Schema.Types.ObjectId,
    ref:'User'
},

text:{
    type:String,
    required:true
},
title:{
    type:String,
    required:[true,'Please enter title'],
    
},
tags:{
    type:[String]
},
name:{
    type:String
},
avatar:{
    type:String
},
likes:[
    {
        user:{
            type:Schema.Types.ObjectId,
            ref:'User'
        }
    }
],



comments:[
    {
        user:{
            type:Schema.Types.ObjectId,
            ref:'User'
        },
      
        text:{
            type:String,
            required:true,
            
        },
        name:{
            type:String
        },
        avatar:{
            type:String
        },
        date:{
            type:Date,
            default:Date.now
        }
    }
],
date:{
    type:Date,
    default:Date.now
}


})
module.exports=Post=mongoose.model('Post',PostSchema)

Whatever you are calling .includes() (or .map() on is not defined at the time that it is being called.

what can be the reason for this? the savedPosts is stored inside User model.Do you suggest any solution for this?

I suggest putting some breakpoints in your code so that you can inspect what the values are throughout the execution.