ı want to make auth in ionic 3 with laravel api.
when ı click sigup button my signup info is inserted database very vell. but it doesnt go another page , just inserted to database. And ı face this error .
Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/studentpost' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
And facing this warning : Cross-Origin Read Blocking (CORB) blocked cross-origin response http://127.0.0.1:8000/api/studentpost with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
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.");
}
}
service provider
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);
});
});
for give information; my signup info is inserted into database ı can see info in json but ı am facing above errors.