# Error reading a RSS/JSON from my Server

**URL:** <https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612>\
**Category:** ionic-v3\
**Created:** [September 27, 2016, 2:17am UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612 "2016-09-27T02:17:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Corin](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@Corin](https://forum.ionicframework.com/u/Corin)\
**Post date:** [September 27, 2016, 2:17am UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/1 "2016-09-27T02:17:04Z")

</div>

Hi,

I am trying to read a RSS/JSON from my own server and I am always getting this error:

```
{"_body":{"isTrusted":true},"status":0,"ok":false,"statusText":"","headers":{},"type":3,"url":null}

```

Here is my code:

```
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';

@Injectable()
export class FeedService {

  private feedUrl:string = 'http://www.myserver.com/feed/json';  

  constructor(private http: Http) {}

  getItems(): Observable<any[]> {
    return this.http.get(this.feedUrl)
                    .map(this.extractData)
                    .catch(this.handleError);
  }

  private extractData(res: Response) {
    let body = res.json();
    for (var i = 0; i < body.length; i++) {
      if ( body[i].thumbnail ) {
        body[i].thumbnail = body[i].thumbnail.split(',')[0].replace(' ', '?');
      }
      body[i].interested = localStorage.getItem(body[i].id + 'Interested') === 'true' || false;
      body[i].going = localStorage.getItem(body[i].id + 'Going') === 'true' || false;
      body[i].ignore = localStorage.getItem(body[i].id + 'Ignore') === 'true' || false;

      console.log('extractData', body);
    }
    return body || { };
  }

  private handleError (error: any) {
    let errMsg = (error.message) ? error.message :
      error.status ? `${error.status} - ${error.statusText}` : 'RSS Server error';
    console.error(error);
    return Observable.throw(errMsg);
  }
}

```

Any help, please?

---

<div class="post-metadata">

**Author:** ![ankushagg93](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ankushagg93/32/103254_2.png) [@ankushagg93](https://forum.ionicframework.com/u/ankushagg93)\
**Post date:** [October 3, 2016, 8:04pm UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/2 "2016-10-03T20:04:41Z")

</div>

did you solve it? I’m also facing same in rc0.

---

<div class="post-metadata">

**Author:** ![Corin](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@Corin](https://forum.ionicframework.com/u/Corin)\
**Post date:** [October 3, 2016, 9:00pm UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/3 "2016-10-03T21:00:50Z")

</div>

Yes, I’ve added the header (server side):  
header(“Access-Control-Allow-Origin: \*”);

And now its working! 🙂

---

<div class="post-metadata">

**Author:** ![ankushagg93](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ankushagg93/32/103254_2.png) [@ankushagg93](https://forum.ionicframework.com/u/ankushagg93)\
**Post date:** [October 3, 2016, 9:24pm UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/4 "2016-10-03T21:24:57Z")

</div>

Thanks a ton. Struggled too much to solve it, it was working in beta 11 so I thought my server is fine. Saved my half day, already wasted half 😛

---

<div class="post-metadata">

**Author:** ![nagarajsabhahith](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nagarajsabhahith/32/133450_2.png) [@nagarajsabhahith](https://forum.ionicframework.com/u/nagarajsabhahith)\
**Post date:** [December 12, 2016, 6:51am UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/5 "2016-12-12T06:51:09Z")

</div>

I am also getting this problem… How i need to solve this…??

---

<div class="post-metadata">

**Author:** ![gorm](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@gorm](https://forum.ionicframework.com/u/gorm)\
**Post date:** [March 6, 2018, 9:03pm UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/6 "2018-03-06T21:03:59Z")

</div>

here im using a RDS on AWS, and when i try to post a json from ‘ionic running on device’ to the uri, i get the same error response…i’ve been trying to figure out how to add that header you talk about in the server side but i just cant find the answer…

Im using api gateway to get the json sent from device, and pass it to a lambda function (where i make some insert queries to insert values on mysql database)

---

<div class="post-metadata">

**Author:** ![SamiKhan](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/samikhan/32/119040_2.png) [@SamiKhan](https://forum.ionicframework.com/u/SamiKhan)\
**Post date:** [April 26, 2018, 7:47am UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/7 "2018-04-26T07:47:02Z")

</div>

I am finding the same issue do you guys find any luck solving it ?

---

<div class="post-metadata">

**Author:** ![vorya](https://avatars.discourse-cdn.com/v4/letter/v/f1d935/32.png) [@vorya](https://forum.ionicframework.com/u/vorya)\
**Post date:** [December 1, 2019, 10:25am UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/8 "2019-12-01T10:25:40Z")

</div>

I used this code:  
Server side: header(“Access-Control-Allow-Origin: \*”);  
Client side: let headers = new Headers({ “Content-Type”: “application/x-www-form-urlencoded” });  
And the problem was solved

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 1, 2019, 7:30pm UTC](https://forum.ionicframework.com/t/error-reading-a-rss-json-from-my-server/64612/9 "2019-12-01T19:30:15Z")

</div>

> [@vorya](#):
>
> Client side: let headers = new Headers({ “Content-Type”: “application/x-www-form-urlencoded” });

Instead of doing this, I would recommend making your request body a [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams), at which point `HttpClient` will set the content type header properly for you.
