title: SyntaxError: Unexpected token U in JSON at position 0 when i make post request
body: <p>I am making a post request to an api with submit() function which is attached to a ng-click directive sending the data in JSON format, it returns this error.</p>
  
  <p>It is running fine on postman so the error is on client side only.</p>
  
  <p>Also the email and selectedIds variables are not empty.</p>
  
  <p><a href="https://i.stack.imgur.com/8DFeB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8DFeB.png" alt="enter image description here"></a></p>
  
  <p>Here is my controller file:</p>
  
  <pre><code>app.controller('categoryController', ['$scope', '$rootScope', '$sce', '$http', '$timeout','$window', function($scope, $rootScope, $sce, $http, $timeout, $window) {
      $scope.allCategories = {};
      $http({
          method: 'GET',
          url: 'http://qubuk.com:8081/api/v1/alltag'
      })
          .then(function (data) {
              // console.log("DATA:" + JSON.stringify(data.data.categories[0].displayName));
              // console.log("DATA category:" + JSON.stringify(data.data.categories));
              $scope.allCategories = data.data.categories;
          });
  
      $scope.selectedIds = [];
  
      $scope.change = function(category, active){
          if(active){
              $scope.selectedIds.push(category.id);
          }else{
              $scope.selectedIds.splice($scope.selectedIds.indexOf(category.id), 1);
          }
  
          // console.log("SELECTED IDS:" + $scope.selectedIds);
      };
  
      $scope.email = "faiz.krm@gmail.com"
      console.log("email is "+  $scope.email);
  
      $scope.submit = function () {
          var tagsData = {"emailId": $scope.email,
                          "tagsId": $scope.selectedIds};
          console.log("tagsData:" + JSON.stringify(tagsData));
          $http({
              method:'POST',
              url: 'http://qubuk.com:8081/api/v1/user/update/tags',
              data: tagsData
          })
              .then(function (data) {
                  console.log("Ids sent successfully!");
                  alert("successful");
                  $window.location.href = '/app/#/feed';
              })
      };
  
      // console.log("amm Categories:" + JSON.stringify($scope.allCategories));
  }]);
  </code></pre>
  
  <p>edit: the response is not a JSON object... it is a string. I do think error is due to this only... how can i resolve it on the front end...</p>