Unable to get set-cookie value from header with axios reactjs

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

3reactions
stevehindcommented, Apr 25, 2020

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 “”.

2reactions
jaredramirezcommented, Sep 19, 2019

Not sure if this will solve it, but you’re trying to get set-cookies instead of set-cookie. The first is plural and the second is singular.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found