title: Ionic 3 POST request to Laravel
body: <p>I use Cors in laravel, my cors.php is </p>
  
  <pre><code>&lt;?php
  
   namespace App\Http\Middleware;
  
   use Closure;
  
   class Cors
   {
    /**
    * Handle an incoming request.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  \Closure  $next
    * @return mixed
    */
    public function handle($request, Closure $next)
    {
     return $next($request)
      -&gt;header('Access-Control-Allow-Origin', '*')
      -&gt;header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, 
      OPTIONS');
      header('Content-Type:application/json; charset=utf-8');
  
    }
  }
  </code></pre>
  
  <p>Page root is in laravel web.php;</p>
  
  <pre><code>Route::group(['middleware' =&gt; 'cors'], function()
  {
   Route::get('/news_json', 'PagesController@news_json');
   Route::post('/post_request', 'PagesController@post_request');
  });
  </code></pre>
  
  <p>Now, in my ionic app; When I post data this get error. Error.status is '419'. I dont use csrf_token in ionic app.
  I have a function in ionic;</p>
  
  <pre><code>getToken() {
   let token = document.querySelector('meta[property="csrf-token"]')
   ['content'];
    return token;
  }
  </code></pre>
  
  <p>I use meta property in ionic3/src/index.html , this meta propery is;</p>
  
  <pre><code>  &lt;meta property="csrf-token" name="csrf-token" content="{{ 
    csrf_token() }}"&gt;
  </code></pre>
  
  <p>My submit function in ionic ;</p>
  
  <pre><code>  var encrypt = new Encrypt.JSEncrypt();
    encrypt.setPublicKey(pubkey);
  
    var link ='http://172.16.1.19/post_request';
    var myData = JSON.stringify({name: this.data.name, telephone: this.data.telephone, email: this.data.email, ask: this.data.ask});
    var encrypted = encrypt.encrypt(myData);
    var post = {form: encrypted, type: 'baskan'};
  
    var options = new RequestOptions({headers: new Headers({
      'Content-Type' : 'application/x-www-form-urlencoded',
      'X-CSRF-TOKEN': this.getToken()
    })
  
  });
  this.http.post(link, post, options).then((data) =&gt; {
    this.toast.create({
      message: `İsteğiniz başarıyla gönderildi!.`,
      duration: 3000
    }).present();
    this.data.name="";
    this.data.telephone="";
    this.data.email="";
    this.data.ask="";
  }, error =&gt;{
      this.data.ask = error.status;
  });
  </code></pre>
  
  <p>I post to laravel other script but when I post data with ionic ı get a error, this error.status is '419' . Can you help me please ?</p>