Skip to content
Advertisement

Tag: mongoose

Getting Error while posting a request, ValidationError: TodoTask validation failed: user: Cast to ObjectId failed for value

i am getting an error while trying to post a todo to the database. ValidationError: TodoTask validation failed: user: Cast to ObjectId failed for value My function for posting the request : Schema is defined as : Answer Since the user property is defined as a ref you should just store the _id in it: When retrieving user’s information you will

Cast to string failed for value Error when submitting the form, using FileBase from React to convert the image

I have an error when i try to post this schema data into Form.js. Mongoose schema looks like this: Logic for creating post is like this: I’m uploading image as String and I’m converting image using base64 from React like this- When I try to submit form, I get error like – {“message”:”PostMessage validation failed: selectedFile: Cast to string failed

Advertisement