res.cookie is not a function
zakaria-chahboun opened this issue · 1 comments
zakaria-chahboun commented
I want to use the package cookie-parser
BUT
I can't use cookie function in res in my middleware! it gives me an error message res.cookie is not a function
my code look like this:
import cookieParser from "cookie-parser";
polka()
// - body parser
.use(json())
// - cookies parser
.use(cookieParser())
.all("*", (req, res, next) => {
res.cookie("XSRF-TOKEN", req.csrfToken());
next();
})
lukeed commented
Correct, it is not. You have to set it up yourself (until there's an official package, which is definitely planned).
Until then, copying the cookie
example works great: #83 (comment)