Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies support #314

Open
ekottifiok opened this issue Jan 22, 2025 · 2 comments
Open

Cookies support #314

ekottifiok opened this issue Jan 22, 2025 · 2 comments

Comments

@ekottifiok
Copy link

node-mocks-http is an invaluable tool

I would like to access the cookies from the createResponse API

In the image attached when mockResponse is logged on an API that returns a cookie it's available on the response but can't be accessed or so I think

Image

(url)

maybe I'm doing something wrong, would like to guided

@eugef
Copy link
Owner

eugef commented Jan 23, 2025

Are you trying to read set-cookie header in the test or application code?

In application code you can use res.get('set-cookie') https://expressjs.com/en/4x/api.html#res.get
In the test code try res._getHeaders()['set-cookie'] https://github.com/eugef/node-mocks-http/blob/master/lib/mockResponse.js#L802

@ekottifiok
Copy link
Author

yes I'm trying to get the cookie to set it in another request to send

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants