Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I use typescript, how can I use the cookie-parser of express

I want to use cookie-parser in expressjs, but typescript can't find the type of request.cookie. How can I solve it?

screenshot

like image 517
BigTeech Avatar asked Feb 28 '17 03:02

BigTeech


People also ask

How do you use cookie parser in Express?

ExpressJS Online Training Now to use cookies with Express, we will require the cookie-parser. cookie-parser is a middleware which parses cookies attached to the client request object. To use it, we will require it in our index. js file; this can be used the same way as we use other middleware.

What is the use of cookie parser in Nodejs?

The cookie parser parses cookies and puts the cookie information on req object in the middleware. It will also decrypt signed cookies provided you know the secret.


1 Answers

Just make sure that you've imported Request type from express package instead of native request declaration type.

import {Request} from 'express';
like image 175
Vlad Dekhanov Avatar answered Oct 30 '22 14:10

Vlad Dekhanov