title: Angular post method to php
body: <p>I've been trying to post data from angular to php all day but I feel quite stuck. 
  This is my method from angular controller:</p>
  
  <pre><code>function submit() {      
          var JSONObject = {
               "name":$rootScope.name,
               "surname":$rootScope.surname,
               "email":$rootScope.email,
               "review":$rootScope.review
          };
          debugger;
          var Results = UniversalService.PostReview(JSONObject);
      }
  </code></pre>
  
  <p>then it goes to UniversalService where my $http.post method is:</p>
  
  <pre><code>function PostReview(JSONObject) {
          debugger;
          $http.post('http://localhost:8000/creation', JSONObject).then();
          debugger;
      }
  </code></pre>
  
  <p>it goes well until this point when it has to send data to php (my web api service is with Lumen framework)</p>
  
  <p>in my DatabaseController.php I expect to recieve my json object (I am quite beginner so I expect that's where I fail)</p>
  
  <pre><code>public function created(Request $request)
  {
      $inputJSON = file_get_contents('php://input');
      $input= json_decode( $inputJSON, TRUE ); //convert JSON into array
  
      print_r(json_encode($input));
     /* $user=[
          'name'=&gt;$request-&gt;input('name'),
          'surname'=&gt;$request-&gt;input('surname'),
          'email'=&gt;$request-&gt;input('email'),
          'review'=&gt;$request-&gt;input('review'),
      ];
      $time=$this-&gt;getTime();*/
   //  return DatabaseModel::newUser($user);
  
  }
  </code></pre>
  
  <p>in routes.php</p>
  
  <pre><code>$app-&gt;post('/creation', [ 'as'=&gt;'creation','uses'=&gt; 'DatabaseController@created']);
  </code></pre>
  
  <p>I used both get and post here out of desperate and I just can't seem to get it right at all. Also in routes.php I enabled header('Access-Control-Allow-Origin: *'); and I am not sure if I have to do that (and how) in angular side.</p>
  
  <p>what I get is bunch of errors<a href="https://i.stack.imgur.com/Wwic7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wwic7.png" alt="enter image description here"></a></p>
  
  <p>But postman seems to work, I have additional function there and when I enter: <a href="http://localhost:8000/creation" rel="nofollow noreferrer">http://localhost:8000/creation</a> to postman I get null for json object and time from another function that I call in creation()</p>