needle
needle copied to clipboard
Issue setting cookies on POST request using needle Promise
Issue
I am currently trying to send a post request to an endpoint using needle. When I try to append the cookies to the request it sends the cookies in the body instead of setting them in the request headers which is strange, as I can do this without issue when sending them using a GET request. The following is what the output on the server looks like:
body: [Object: null prototype] {
'cookies[token]': '[The token I sent to the endpoint]'
}
Code to Reproduce
The following are multiple ways that I tried to send the cookies, all of which send them in the body:
Following the get request syntax
This works when sending a get request instead of a post request.
needle(
method="post",
url=login_server,
headers={cookies: {token: req.cookies.token}}
)
Following the docs suggested format
This is how the docs say to send the request.
needle(
method="post",
data="",
url=login_server,
options={headers: {cookies: {token: req.cookies.token}}}
)
Expected Behaviour
The token should be appended to the header not the body. The docs do not indicate how this is possible, and if they are different, the functionality for GET and POST for the same promise should not be different.
+1, I'm having the same problem