title: Laravel 5.5 + Vue.js 2.x Proper API requests
body: <p>I am working locally on a Laravel 5.5 project which uses Vue.js 2.5.9 on with XAMP Server.</p>
  <p>I have to load some information to the DOM and refresh it when click &quot;Refresh&quot; button.</p>
  <p>Sometimes the information is loaded and well displayed but sometimes they are not (some of the responses are):</p>
  <blockquote>
  <p><strong>Error 429:</strong> { &quot;message&quot;: &quot;Too Many Attempts.&quot; }</p>
  <p><strong>Error 500:</strong> { &quot;message&quot;: &quot;Server Error.&quot; }</p>
  </blockquote>
  <p>I managed to &quot;solve&quot; the first issue (<em>error 429</em>) by increasing the Middleware throttle in <strong>Kernel.php</strong> from <code>'throttle:60,1',</code> to <code>100,1</code>)</p>
  <p>But the second error I am not sure why I am get it sometimes and sometimes not.</p>
  <p>I have this in my <strong>APIController</strong> (for example):</p>
  <pre><code>public function users()
  {
      $users = User::all();
  
      return response()-&gt;json($users);
  }
  </code></pre>
  <p>Then in <strong>app.js</strong> I call the methods in the created hook like this:</p>
  <pre><code>const app = new Vue({
      el: '#app',
      data: {
          ...
          totalUsers: 0,
          ...
      },
      created: function() {
          ...
          this.loadUsers();
          ...
      },
      methods: {
          ...
          loadUsers: function() {
          axios.get('/api/admin/users')
              .then(function (response) {
                  app.totalUsers = response.data.length;
              });
          },
          refreshData: function() {
              this.loadUsers():
          },
          ...
      }
  });
  </code></pre>
  <p>Maybe should I replace <code>$users = User::all()</code> to <code>$users = User::count()</code> to avoid loading &quot;too much data&quot; in API requests?</p>