title: AngularJS $http - slow
body: <p>Im using AngularJS on front-end and PHP on back-end that is hosted in Google App Engine. Now when i try to fetch JSONP data directly from server it goes fast, when i use a Google service the time increases with almost 1s. Very short: Im getting my data very slow, it takes 1.3-1.8s to render data on screen. </p>
  
  <p>This is my Client-code-Controller:</p>
  
  <pre><code>angular
      .module('RDash')
      .controller('tables-ctrl5', ['$scope','$http', function($scope,$http) {
          $http({
              method: 'jsonp',
              url: 'https://gtmdocx.appspot.com/test5?callback=JSON_CALLBACK',
              headers: {"Content-Type":"application/json"}
          }).then(function ListCtrlresponses(response) {
  
              $scope.GTMWorkspacesTags = response.data.tag;
              console.log(response.data.tag);
              $scope.GTMWorkspacesTagsLength = response.data.tag.length;
  
          }, function Error(response) {
              $scope.users = response.statusText;
          });
      }])
  </code></pre>
  
  <p>im using ng-repeat:</p>
  
  <pre><code>   &lt;div class="col-lg-6"&gt;
      &lt;rd-widget&gt;
        &lt;rd-widget-header icon="fa-tasks" title="Google Tag Manager - URL: http://gtmdocx.appspot.com/test3 (LISTE AV TAGS I WORKSPACE) = Hent ut PATH fra LISTE av Workspace (EX: accounts/1746756959/containers/7454209/workspaces/8)"&gt;
        &lt;/rd-widget-header&gt;
        &lt;rd-widget-body classes="medium no-padding"&gt;
          &lt;div class="table-responsive"&gt;
            &lt;table class="table table-striped" ng-controller="tables-ctrl5"&gt;
              &lt;thead&gt;
              &lt;tr&gt;
                &lt;th&gt;AccountID&lt;/th&gt;
                &lt;th&gt;ContainerID&lt;/th&gt;
                &lt;th&gt;TagName&lt;/th&gt;
                &lt;th&gt;Path&lt;/th&gt;
                &lt;th&gt;test&lt;/th&gt;
  
  
              &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
              &lt;tr ng-repeat="workspace in GTMWorkspacesTags"&gt;
                &lt;td&gt;{{ workspace.accountId }}&lt;/td&gt;
                &lt;td&gt;{{ workspace.containerId }}&lt;/td&gt;
                &lt;td&gt;{{ workspace.name }}&lt;/td&gt;
                &lt;td&gt;{{ workspace.path }}&lt;/td&gt;
                &lt;td&gt;{{GTMWorkspacesTagstest}}&lt;/td&gt;
  
              &lt;/tr&gt;
  
              &lt;/tbody&gt;
            &lt;/table&gt;
          &lt;/div&gt;
        &lt;/rd-widget-body&gt;
        &lt;rd-widget-footer&gt;
          Footer
  
        &lt;/rd-widget-footer&gt;
      &lt;/rd-widget&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>Now this is my PHP-code: very simple and straight forward: (PS: using slim)</p>
  
  <pre><code>// 4) Gets all TAGS related to this WORKSPACE
  $app-&gt;get('/test5', function (Request $request, Response $response) {
      $client = new Google_Client();
      $client-&gt;setApplicationName("gtmdocx");
      $client-&gt;setAuthConfig('service_account.json');
  
      $client-&gt;setScopes(['https://www.googleapis.com/auth/tagmanager.readonly',
          'https://www.googleapis.com/auth/tagmanager.manage.accounts',
          'https://www.googleapis.com/auth/tagmanager.edit.containers',
          'https://www.googleapis.com/auth/tagmanager.publish'
      ]);
  
      $service = new Google_Service_TagManager($client);
      $containers = $service-&gt;accounts_containers_workspaces_tags-&gt;listAccountsContainersWorkspacesTags('accounts/1746756959/containers/7454209/workspaces/8');
      echo $_GET['callback'] . '('.json_encode($containers).')';
  
  });
  </code></pre>
  
  <p>If you look at the timing on response:
  <a href="https://i.stack.imgur.com/mLBdb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mLBdb.png" alt="enter image description here"></a></p>
  
  <p>I hope someone has experienced this before. This is really bothering me that it is using so much time to render. When i type in directly the URL in browser i get response right away, but in angularjs as front its slow. Im using JSONP to fetch because of CORS, can this be the problem?</p>