简体   繁体   中英

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. 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? 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.

Tried both - 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'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM