Ionic API Parsing Error


#1

Hi,
Ionic fan here, I recently updated my Ionic environment to Ionic 3 for one of my applications. Everything was working till Yesterday. Now I am stuck. I am calling an API using http.get() and showing the response in view file.

story-detail.ts

ionViewWillEnter() {
        let d = new Date();
        let timezone = d.getTimezoneOffset() / -60;
		let param = {
            story_id: this.navParams.get('story_id'),
            timezone: timezone,
            uid: ''
        }

        let params = this.Obj2Param(param);
		this.http.get('https://xxxxxxxxx.com/dev/api/v1/story/info?' + params)
		.map(res => res.json())
		.subscribe(data => {
			console.log(data.data);
			this.story = data.data;
		});
}

story-detail.html

<ion-content>
	<div class="story-cover">

	</div>

	<section padding>
		<div class="section-title">
			{{story.story_title}}
		</div>
		
	</section>
	
	
</ion-content>

It is as easy as it looks but I don’t know why its giving me this error:

However, when I check my console, it displays the Object correctly.

Any help would be appreciated, Thanks!


#2

I think the issue is that the error is being thrown when the view is being rendered, and the data is arriving after the “view is going to enter”…

To avoid the error try doing this

<div class="section-title">
	{{story?.story_title}}
</div>

#3

Genius!!! Thanks for saving my life @elvis_gn Cheers!