title: Why is my API call receiving repeat data when it should be random?
body: <p>So I'm building a React application that is making API calls to receive a random object containing a quote, author, and some other information. When the component mounts(on page refresh) the object is randomized. However, the button bound to the same function that initially pulls the API only receives the same object as when the page loaded. The randomization is provided from the endpoint and not within my code.</p>
  
  <p>Not sure why this wouldn't work as the data received is unique on page refresh, but not on the onClick event.</p>
  
  <p>So here's some of my code that I'm using:</p>
  
  <p>My API fetch function: </p>
  
  <pre><code>httpCallout(){
      fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&amp;filter[posts_per_page]=1')
      .then(response =&gt; response.json())
      .then((data) =&gt; {
        const quote = data[0].content;
        this.setState({
          quote: quote,
          author: data[0].title
        });
      });
    }
  </code></pre>
  
  <p>The call within the lifecycle function:</p>
  
  <pre><code>  componentDidMount(){
      this.httpCallout();
  
    }
  </code></pre>
  
  <p>and then the element </p>
  
  <pre><code>&lt;button id="new-quote" className="btn btn-light" onClick={this.httpCallout}&gt;New Quote&lt;/button&gt;
  </code></pre>
  
  <p>So again, I'm expecting to be receiving a new object containing new data on each click event, however, I'm being fed the same data as on the page load.</p>
  
  <p>EDIT:
  It was simply data being cached. I added <code>{cache: "no-cache"}</code> into the fetch request and it was solved. The question has been marked as a duplicate, however I find the solution required to be slightly different since my issue was using the fetch API and not using jQuery or AJAX.</p>