Unable to get set-cookie value from header with axios reactjs
See original GitHub issueI am using react js and i have an axios.get function which is supposed to return me a value of set-cookie . Before axios i tried fetch but when running response.headers.get(“set-cookie”) it gives null . For axios , response.headers[“set-cookie”] gives undefined . Why headers don’t contain set-cookie ?
axios.get(server + '/QryIsapi.dll?Login&login=' + username + '&password=' + password + '&action=login' + '&Expire=' + !stay_connected, {
headers: new Headers({
"Content-Type": 'text/plain',
"Accept": "text/plain",
"Accept-Language": accept_language
}),
withCredentials: true
}).then(response => {
console.log(response.headers["set-cookies"]) //gives undefined
}).catch(function (data) {
console.log("Login : ", data)
})
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6
Top Results From Across the Web
Unable to get set-cookie value from header with axios reactjs
My ASP .NET web api server is returning cookies in response to axios get request but i am UNABLE to get set-cookie header...
Read more >react axios get cookie from response - You.com - You.com
So the answer should be as simple as specifying the value of the Origin request header in the server.use.cors.origin value. Open side panel....
Read more >Cookies, document.cookie - The Modern JavaScript Tutorial
Upon sign in, the server uses the Set-Cookie HTTP-header in the response to set ... It can submit a form there, but can't...
Read more >SameSite cookies - HTTP - MDN Web Docs
The SameSite attribute of the Set-Cookie HTTP response header allows you ... Note that insecure sites ( http: ) can't set cookies with...
Read more >Handling cookies with axios - Medium
After even more research, I observed that setting Cookie as header and passing the cookie in it was a method suggested. Cookie: name=value; ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think this is a typo problem.
I’m also using axios.post, and have confirmed (chrome dev tools, insominia) that the server is sending a cookie. However printing response.header shows no set-cookies header, and printing document.cookie shows “”.
Not sure if this will solve it, but you’re trying to get
set-cookies
instead ofset-cookie
. The first is plural and the second is singular.