Skip to content
Advertisement

Tag: express

Get user data in request.user using express and typescript

I’m trying to create a middleware to ensure the user is admin, but when I print request.customer, the result is undefined. This is what I’m doing: request.customer returns this: Property ‘customer’ does not exist on type ‘Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>’ So I declared the express namespace by adding the customer id, like this: I have no errors but

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

Advertisement