Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Get json property/value inside a promise function

$
0
0

@pisxid12 wrote:

Hi,
I need to get the JSON values, but there is an error that says “user doesn’t exists in the Object type”:

My function:

	search(path): Promise<any> {
		return this.http.get(path)
			.toPromise()
			.then(
			response => {           // Success
				if (response != false) {
					this.storage.set('user', JSON.stringify(response));
					this.storage.set('alerts', 920);

					console.log(response.user.age); ///<---- Here the error

					return response;
				} else {
					return null;
				}
			},
			error => {              // Error
				return null;
			});
	}

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>