2

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'm makin a req to a website I don't own. I'm not in control of the server. Just tryna ensure that when I make a req to let's say google.com/joe, the contents it returns would be if no google account was logged in, even if I am logged in. – Display name May 07 '20 at 13:58
  • Try doing it in NodeJS with the ```node-fetch``` package, to see if results are as expected? –  May 07 '20 at 14:02
  • Want to iterate that I have tried it and tested adding the cache parameters with fetch and it returns results consistent with being logged in - I want logged out even if I am logged in. Using node-fetch would be redundant and produce identical results. – Display name May 07 '20 at 14:08
  • so if its a session cookie which you're trying to not send, maybe try setting an empty cookie header to overide what might be sent as default, [see](https://stackoverflow.com/questions/34815845/how-to-send-cookies-with-node-fetch) on how to set cookies – Lawrence Cherone May 07 '20 at 14:14
  • i tried this and this did not work. good idea tho – Display name May 07 '20 at 14:28

1 Answers1

4

I figured it out! Here's the answer for future people that will surely have this question.

fetch('https://example.com', {credentials: 'omit'});
Iván Nokonoko
  • 4,888
  • 2
  • 19
  • 27