If anyone knows what the problem is, I need help for my ionic 3 application that calls a laravel api. It works correctly when you run my ionic application from the web, calling localhost: 8000 / api / employees, however I need to run the application from a device, so change localhost to the ip where the laravel project is running, presents the following error.
Failed to load resource: net :: ERR_CONNECTION_TIMED_OUT Could not get any response.
my code is as follows:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
@Injectable()
export class RestapiProvider {
url: string = "http://192.168.234.141:8000/api/empleados";
//localhost:8000/api/empleados
constructor(public http: HttpClient) {
console.log('Hello RestapiProvider Provider');
}
getUsers(){
return new Promise(resolve => {
this.http.get(this.url).subscribe( data => {
resolve(data);
}, err => {
console.log(err);
});
});
}
addUser(data) {
return new Promise((resolve, reject) => {
this.http.post(this.url+'/api/empleados', JSON.stringify(data))
.subscribe(res => {
resolve(res);
}, (err) => {
reject(err);
});
});
}
}
Thank you very much to anyone who can answer.