# Ionic http fetch remote server

**URL:** <https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551>\
**Category:** Ionic Native\
**Created:** [September 7, 2017, 5:54am UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551 "2017-09-07T05:54:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![caribesoft](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/caribesoft/32/12570_2.png) [@caribesoft](https://forum.ionicframework.com/u/caribesoft)\
**Post date:** [September 7, 2017, 5:54am UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551/1 "2017-09-07T05:54:54Z")

</div>

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/](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 :

```auto
ERROR Object { _body: error, status: 0, ok: false, statusText: "", headers: Object, type: 3, 
url: null }

```

Here is my ts code -\> home.ts

```auto
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](https://www.reddit.com/r/gifs/top/.json?limit=10&sort=hot) works fine.  
Any ideas or comments. Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Jacktoolsnet](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jacktoolsnet/32/107318_2.png) [@Jacktoolsnet](https://forum.ionicframework.com/u/Jacktoolsnet)\
**Post date:** [September 7, 2017, 6:54am UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551/2 "2017-09-07T06:54:58Z")

</div>

Perhaps the firewall on your server blocks the port 9090.

---

<div class="post-metadata">

**Author:** ![wingly](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wingly](https://forum.ionicframework.com/u/wingly)\
**Post date:** [September 7, 2017, 7:39am UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551/3 "2017-09-07T07:39:27Z")

</div>

You should try to avoid hardcoded ips inside your app let the dns resolve it

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [September 7, 2017, 8:15am UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551/4 "2017-09-07T08:15:32Z")

</div>

How are you testing?  
What is your `ionic info`?

Note that the IP is also using `http`, the proper API is using `https`.

---

<div class="post-metadata">

**Author:** ![caribesoft](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/caribesoft/32/12570_2.png) [@caribesoft](https://forum.ionicframework.com/u/caribesoft)\
**Post date:** [September 7, 2017, 2:23pm UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551/5 "2017-09-07T14:23:19Z")

</div>

Sorry there was an error in the server, now is running OK. I mean the web service is running OK, but I still have the problem, Angular 2 or Ionic 2 does not understand the URL as an IP Address. I also made some test with CURL - PHP and it works fine. Hope somebody can give me some tips !

---

<div class="post-metadata">

**Author:** ![caribesoft](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/caribesoft/32/12570_2.png) [@caribesoft](https://forum.ionicframework.com/u/caribesoft)\
**Post date:** [September 9, 2017, 3:54am UTC](https://forum.ionicframework.com/t/ionic-http-fetch-remote-server/104551/7 "2017-09-09T03:54:10Z")

</div>

Finally I found that the problem was with the CORS. The solution, I configure a proxy on ionic.config.json file, and now Http can work with Ip address.
