0
I need to request a webserver in Ionic 2 and I have the following code :
constructor(private navController: NavController, public http: Http) {
var url = 'http://localhost/APIPortManager/teste.php';
var response = this.http.get(url)
response.toPromise().then(response => {
let dados = response.json()
alert (dados)
}).catch(err => {
//let erro = err.json();
alert ("erro")
});
//return response;
//alert(response.toPromise()); // return object object
}
However only returns me the error, how do I display the text ? Thank you Ps: I know the correct is not in the controller, I just need to display the code that pg has, I don’t even need the json if pg display hi I want to give Alert on hi just that. Update, error in console :
Xmlhttprequest cannot load http://localhost/. In the 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost:8100' is therefore not allowed access.