Remote url not working but local url working for http ionic


#1

Hi All,
home.ts
public getFuelCities() {
let URL = “assets/data/locations.json”;
// let URL = “http://fuelpriceindia.herokuapp.com/cities.json

this._http.get(URL)
.map(res => res.json())
.subscribe(data => {
this.fuelcities = data.cities;
console.log(JSON.stringify(data.cities));
});
}

home.html
<ion-item *ngIf=“fuelcities”>
Choose City
<ion-select [(ngModel)]=“city” (ngModelChange)=“getFuelRates()”>
<ion-option *ngFor=“let cityName of fuelcities”>{{cityName}}

The dropdown has its data when I call json locally using let URL = “assets/data/locations.json”;
But it doesn’t work when I call the same data from external url
let URL = “http://fuelpriceindia.herokuapp.com/cities.json

I tried settting this url in proxy too:

“proxies”: [
{
“path”: “/api”,
“proxyUrl”: “http://fuelpriceindia.herokuapp.com
}
]

But nothing happend, could you please assist me on this. this is urgent for me.

Regards,
Rajesh


#2
"proxies": [
    {
      "path": "/api",
      "proxyUrl": "http://fuelpriceindia.herokuapp.com"
    }
  ]



public getFuelCities() {
  let URL = "assets/data/locations.json";
//  let URL = "http://fuelpriceindia.herokuapp.com/cities.json"

  this._http.get(URL)
    .map(res => res.json())
    .subscribe(data => {
      this.fuelcities = data.cities;
      console.log(JSON.stringify(data.cities));
  });

}




<ion-card class="animated bounceInDown" color="cloudbrust">
  <ion-card-content>
    Choose the city name for which you want to know the current fuel prices.
    <ion-item *ngIf="fuelcities">
      <ion-label>Choose City</ion-label>
      <ion-select [(ngModel)]="city" (ngModelChange)="getFuelRates()">
        <ion-option *ngFor="let cityName of fuelcities">{{cityName}}</ion-option>
      </ion-select>
    </ion-item>

  </ion-card-content>
</ion-card>

#3

“it doesn’t work” is no error description.
What happens when and what should normally happen?
Where and what are you testing?

Post your ionic info output please.