@wiredmartian wrote:
I’m retrieving XML from this forexfactory.net and converting it to JSON using X2JS. I’m able to achieve this on my provider, however I can’t use the data on my page since I can’t map my response to json on the provider “res.json()”.
/** The Provider function*/
getNews(){ let x2js = new X2JS(); return this.http.get('xml url').map(res =>{ let xml = res.text(); return x2js.xml2js(xml); }); }
/** The page */
export class NewsPage { news: any[]; constructor(private newsProv: NewsProvider) { } ionViewDidLoad() { this.newsProv.getNews().subscribe(res =>{ this.news = res; }, (err) =>{ console.log(err); }); } }
On the line ‘this.news = res;’ I get an error saying “Type {} is not assignable to type ‘any[]’”. And I understand from this issue that its because I didn’t map my response to json “res.json()”. And I’ve tried to on my provider, but I get an error.
Posts: 1
Participants: 1