ı had some error about signup but then ı installed this composer require barryvdh/laravel-cors
and add this line to app/Http/Kernel.php
protected $middleware = [
// ...
\Barryvdh\Cors\HandleCors::class,
];
its worked for auth(ı mean post method) but then after ı installed this package get method not worked( for giving info; before making this installing my get method worked very well). so please help me ; how can ı make work get method.
signup.ts
export class SignUpPage {
responseData : any;
userData = {"full_name":"", "password":"","email":"","name":""};
signup() {
if(this.userData.full_name && this.userData.password && this.userData.email && this.userData.name){
//Api connections
this.authProvider.postData(this.userData, "signup").then((result) =>{
this.resposeData = result;
if(this.resposeData.userData){
console.log(this.resposeData);
localStorage.setItem('userData', JSON.stringify(this.resposeData) )
this.navCtrl.push(HomePage);
}
else{
this.presentToast("Please give valid username and password");
}
}, (err) => {
console.log("this error: "+ JSON.stringify(err));
});
}
else {
console.log("Give valid information.");
}
}
auth service
postData(credentials, type){
return new Promise((resolve, reject) =>{
let headers = new Headers({
'Content-Type' : 'application/json'
});
let options = new RequestOptions({ headers: headers });
this.http.post(apiUrl, JSON.stringify(credentials), {headers: headers}).
subscribe(res =>{
resolve(res.json());
}, (err) =>{
reject(err);
});
});