[英]Making a get request as if the browser is in incognito mode?
I'm making a get request using fetch to a given url that lets say is joe.com/123.我正在使用 fetch 向给定的 url 发出获取请求,可以说是 joe.com/123。 The contents are different whenever I'm logged into the website versus when I'm logged out of the website.
当我登录网站和退出网站时,内容是不同的。 How do I ensure that anytime I make the request to the url, even if I am logged in, it returns a result that is consistent with the logged out response?
如何确保无论何时我向 url 发出请求,即使我已登录,它也会返回与注销响应一致的结果? I have tried adding to the fetch request the cache parameter, setting it "no-cache" and "no-store" but both values did not help - it returns the logged in response.
我尝试将缓存参数添加到获取请求中,将其设置为“no-cache”和“no-store”,但两个值都没有帮助 - 它返回登录的响应。
Tried both - fetch(bruh, {cache:"no-cache"}) & fetch(bruh, {cache:"no-store"})都试过了 - fetch(bruh, {cache:"no-cache"}) & fetch(bruh, {cache:"no-store"})
bruh = window.location.toString();
bro = await fetch(bruh).then(result =>result.text()).then(text=>text);
I figured it out.我想到了。 Here's the answer for future people that will surely have this question.
这是未来肯定会有这个问题的人的答案。
fetch('https://example.com', {credentials: 'omit'});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.