Fetch 请求默认是不带cookie的。需要设置fetch的第二个参数; 先来看下,请求头部信息Request
method - 使用的HTTP动词,GET, POST, PUT, DELETE, HEADurl - 请求地址,URL of the requestheaders - 关联的Header对象referrer - referrermode - 请求的模式,主要用于跨域设置,cors, no-cors, same-origincredentials - 是否发送Cookie omit, same-originredirect - 收到重定向请求之后的操作,follow, error, manualintegrity - 完整性校验cache - 缓存模式(default, reload, no-cache)
其中改变credentials 参数来让请求中包含cookie
fetch(
url,
{credentials: 'include'})