I’m trying to consume a web service from my Ionic App using Angular Http. I’m following Josh Morony Example -> https://www.joshmorony.com/using-http-to-fetch-remote-data-from-a-server-in-ionic-2/ but I´m receiving the following error when I use an IP address in the url :
ERROR Object { _body: error, status: 0, ok: false, statusText: "", headers: Object, type: 3,
url: null }
Here is my ts code -> home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
posts: any;
url: string = 'http://200.33.191.161:9090/reservationsapi/31922904?idHotel=2';
constructor(public navCtrl: NavController, public http: Http) {
this.http.get(this.url).map(res => res.json()).subscribe(data => {
this.posts = data.data.children;
});
console.log(this.posts);
}
}
The problem is when I use IP address, if I use the url of the example:
https://www.reddit.com/r/gifs/top/.json?limit=10&sort=hot works fine.
Any ideas or comments. Thank you in advance!