response.headers.get(“ set-cookie”)在获取React js时返回null,并且未为axios定义

时间:2019-06-27 08:09:09

标签: reactjs fetch

我有一个提取功能,可以让我配置一些参数。我想获取set-cookie的值,但它给我null。尽管在网络标题中,我确实看到了具有完整值的set-cookie。我什至尝试了axios而不是fetch,并且标头中没有set-cookie,它给出了未定义的信息 这是我的提取物:

  fetch(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
  }),
  credentials: 'include'
  }).then(response => decodeContent(response).then(jsonData => {
  var CookieString = response.headers.get("set-cookie"); 
  console.log(CookieString)

    })).catch(function (data) {

  console.log("Login : ", data) }

这是我从网络的响应标头中得到的:

    HTTP/1.1 200 OK
    Server: Microsoft-IIS/10.0
    Date: Thu, 27 Jun 2019 08:06:09 GMT
    Connection: close
    Set-Cookie: APS_User=2570AAC6249A90D1FDCFDFFAC78BB36C69D6;HttpOnly; 
    expires=Sun, 21-Jun-2020 08:06:09 GMT; path=/43 
    Set-Cookie: TESTCookie=1; expires=Sun, 21-Jun-2020 08:06:09 GMT; 
    path=/43 
    Set-Cookie: anonyme=false; expires=Sun, 21-Jun-2020 08:06:09 GMT; 
    path=/43 
    Set-Cookie: SSOEnable=0; expires=Sun, 21-Jun-2020 08:06:09 GMT; 
    path=/43 
    Set-Cookie: Expire=true; expires=Sun, 21-Jun-2020 08:06:09 GMT; 
    path=/43 
    Set-Cookie: APS_TIME_CONNECTION=1561622769; expires=Sun, 21-Jun-2020 
    08:06:09 GMT; path=/43 
    Expires: 0
    Content-Type: text/plain; charset=iso-8859-1

我说过凭据:“ include”是空值的原因,但是即使我删除了它,值也没有变化

0 个答案:

没有答案