Ionic 2 Reading json

Asked

Viewed 182 times

0

2 answers

-1

To appear in Alert your result is necessary to use a conversational method from object to string. ex: JSON.stringify(date);

-1


The code alert(data.id); will not display anything at all. After all date is a vector. To access the id attribute, you need to specify the vector position or use a loop (for, foreach, etc).

Example:

alert(data[0].id);
  • Diego, in this case, put the flags stating that the question is incomplete! Note: From my point of view, this still answers the question. After all I’m showing the problem with his code.

  • Diego: "However my class Alert only returns Undefined... How can I fix ?". My answer answers this perfectly to the details that have been provided.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.