My controller is not returning the request body from the POST request. I am trying to make a login in Ionic that will direct to my laravel server.
Laravel : Controller
public function store(Request $request){
return $request->all();
}
Ionic : register.ts (src: http://www.nikola-breznjak.com/blog/javascript/ionic3/posting-data-ionic-3-app-php-server/)
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Http } from '@angular/http'; //https://stackoverflow.com/questions/43609853/angular-4-and-ionic-3-no-provider-for-http
@Component({
selector: 'page-register',
templateUrl: 'register.html'
})
export class RegisterPage {
data:any = {};
constructor(public navCtrl: NavController, public http: Http) {
this.data.username = '';
this.data.response = '';
this.http = http;
}
submit() {
var link = 'http://127.0.0.1:777/api/user';
var myData = JSON.stringify({username: this.data.username});
this.http.post(link, myData)
.subscribe(data => {
this.data.response = data["_body"]; //https://stackoverflow.com/questions/39574305/property-body-does-not-exist-on-type-response
}, error => {
console.log("Oooops!");
});
}
}
So I investigated it, and I notice the payload is in JSON like this: .
But when I try to use json_decode() for it, the Laravel Validation won't work.