title: POST-request from AngularJS to Laravel
body: <p>I'm trying to send a POST-request from my AngularJS-app to an independent Laravel backend (on localhost), but can't figure out the X-CSRF-TOKEN stuff. At least I think that's the problem.</p>
  
  <p>I'm always recieving this error in console: </p>
  
  <pre><code>POST http://localhost/public/drinks 419 (unknown status)
  </code></pre>
  
  <p>I've added this to index.html in my AngularJS app:</p>
  
  <pre><code>&lt;script&gt;angular.module("myCaffeineIntake").constant("CSRF_TOKEN", '{{ csrf_token() }}');&lt;/script&gt;
  </code></pre>
  
  <p>And here is the code from my controller:</p>
  
  <pre><code>$scope.answer = function(newdrink, CSRF_TOKEN) {
       newdrink._token = CSRF_TOKEN;
       newdrink._method = "post";
  
       $http({
           method : "POST",
           url : "http://localhost/public/drinks",
           data : newdrink
       }).then(function mySuccess(response) {
  
       }, function myError(response) {
           console.log("error");
       }
   );
  </code></pre>
  
  <p>And my Laravel-controller:</p>
  
  <pre><code>public function store(Request $request)
  {
      $drink = new Drink;
      $this-&gt;validate(request(),[
          'Name' =&gt; 'required',
          'Size' =&gt; 'required',
          'Caffeine' =&gt; 'required',
          'Url' =&gt; 'required'
      ]);
  
      Drink::create([
          'Name' =&gt; request('Name'),
          'Size' =&gt;  request('Size'),
          'Caffeine' =&gt; request('Caffeine'),
          'Amount' =&gt; 0,
          'Url' =&gt; request('Url'),
          'created_at' =&gt; time(),
          'updated_at' =&gt; time(),     
      ]);
  }
  </code></pre>
  
  <p>What have I missed?</p>