How to run Ionic App against a localhost API (Dev App)

912 views Asked by At

I'm trying to simulate my Ionic app with the "Ionic DevApp" in my iOS device but, I can't connect to the localhost api that is running in my computer from the device. I've changed the API request endpoint to my computer's local IP address but nothing changes. This the URL example I'm using:

http://192.168.0.145:8080/countries

This is the full provider:

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';   

@Injectable()
export class CountryProvider {

private url: string; 

constructor(public http: HttpClient) {
  this.url = "http://192.168.0.145:8080/countries";
}

getCountries() {
  return this.http.get(this.url);
} 

Of course, It's working correctly if I run the app in the computer browser. I've checked the same URL on the iOS device browser and it's fine.

0

There are 0 answers