[英]Send cookie and API Key on the fetch request
I am sending a GET request to an API.我正在向 API 发送 GET 请求。 The browser must send a cookie and an API Key on the fetch request .
浏览器必须在获取请求上发送一个 cookie 和一个 API 密钥。
The problem that I face is the following:我面临的问题如下:
fetch(urlToRequest, {
method: "GET",
mode: "cors",
credentials: "include"
})
.then((response) => {
console.log(response);
})
.catch ((error) => {
console.log(error)
});
fetch(urlToRequest, {
method: "GET",
mode: "cors",
credentials: "include",
headers: {"api-key": apiKey}
})
.then((response) => {
console.log(response);
})
.catch ((error) => {
console.log(error)
});
Is this behave normal?这种行为正常吗? Shouldn't the browser send the cookie and the api key aswell?
浏览器不应该发送 cookie 和 api 密钥吗?
it's a Chrome problem,in some cases Chrome debugger do not show the cookie.这是 Chrome 的问题,在某些情况下 Chrome 调试器不显示 cookie。 The cookie has been sent i think.
我认为cookie已发送。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.