I'm new to Ionic and I'm having trouble getting data from a database in a server.
What I'm trying to do is to connect Ionic to the database in a server through a laravel app.
this.http
.get('http://127.0.0.1:8000/retrieve_data.php')
.subscribe((data : any) =>
{
console.dir(data);
this.items = data;
console.log(this.items);
},
(error : any) =>
{
console.dir(error);
});
Where retrieve_data.php is a file that contains the database connection and query, but nothing shows up in my app.
So I tried doing the same thing but with a local host. If I run the retrieve_data.php file directly from my browser it shows
[{"id":1,"name":"Diego Rodriguez","email":"drodriguezm@fastfit.cl","password":"fastfit","remember_token":null}]
Which is the answer from the query to the db in the localhost. But when I try to do the same thing in Ionic like: this.http.get('http://localhost/retrieve_data.php')
I get nothing.
Please help :(