I need to make a request to a webserver on 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
}
But only the error returns, how do I display the text? Thank you Ps: I know the correct one is not in the controller, I just need to display the code that pg has, I do not even need json if the pg display hi I want to give alert on hi only this. Update, console error:
XMLHttpRequest can not load link . At the 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' link ' is therefore not allowed access.