below my service code
public login(loginRequest:LoginRequest):Observable<AuthResponse> {
alert(JSON.stringify(loginRequest))
const myHeaders = new HttpHeaders({'Content-Type':'application/json', 'Accept':'application/json'});
return this.http.post<AuthResponse>(this.config.apiBase + '/login', JSON.stringify(loginRequest), {headers: myHeaders})
.concatMap(data => {
return Observable.of(data);
});
}
this is my signin code
singIn() {
if(this.credentials.login.length == 0 || this.credentials.password.length == 0) {
this.tosatService.showToast('Phone or Password cannot be empty!');
} else {
this.tosatService.presentLoading('Logging in');
let subscription:Subscription = this.service.login(this.credentials).subscribe(data => {
this.tosatService.dismissLoading();
let authResponse:AuthResponse = data;
window.localStorage.setItem('api_key', authResponse.token);
window.localStorage.setItem('user', JSON.stringify(authResponse.user));
//this.navCtrl.setRoot();
}, err=> {
this.tosatService.dismissLoading();
this.tosatService.presentErrorAlert("Unable to login with provided credentials");
});
this.subscriptions.push(subscription);
}
}
this is my model.ts
export class LoginRequest {
login: string;
password: string;
constructor(login: string, password: string) {
this.login = login;
this.password = password;
}
}
when i trying to submit data to the server showing this error
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://mydomain.com/demo/append/index.php/login. (Reason: CORS request did not succeed
how can i fix this issue
please help me out
thanks in advance