高级前端
js
【Q295】fetch 中 credentials 指什么意思,可以取什么值

fetch 中 credentials 指什么意思,可以取什么值

Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 297 (opens in a new tab)

Author 回答者: shfshanyue (opens in a new tab)

credentials 指在使用 fetch 发送请求时是否应当发送 cookie

  • omit: 从不发送 cookie.
  • same-origin: 同源时发送 cookie (浏览器默认值)
  • include: 同源与跨域时都发送 cookie

Author 回答者: shen076 (opens in a new tab)

标题单词拼错了

Author 回答者: shfshanyue (opens in a new tab)

@shen076 已修正