[Vuejs]-Can't create REST API with a longer path

0👍

The cast error is pointing that you might be using a wrong parameter to find the data,From looking a the above code i reckon you are trying to retrieve all the photos of the queried user,If that is the case user schema must have photo key associated to photos collection with objectId’s like shown below, hence you can query for the user and populate the images parameter,which would give list of images associated to the user .Look for collection association in mongoose with OBJECTID What's Mongoose error Cast to ObjectId failed for value XXX at path "_id"? this link explains the error you got.hope its of some help to you

{
   "user":String,
   "images":["imgs":{
                "type":mongoose.Schema.Types.ObjectId,
                "ref":"Photos"  
               }]

}

Leave a comment