How to deal with non-JSON return?


Dear friens,
A web-service gets values by fallowing Address:

and return a non-JSON result something like “Az1Bx2Cc3Dv4E5bF6nG8mHr7ItJh9KjLp” which is hashed.
how I can get this kind of return or unstructured returns such as 1 for success and -1 for failures?\


Just use response.text() rather than response.json().


Thanks Mirko,
Last year I used your Ionic 1 tutorial that was great.


Dear Mirko,
I used the flowing code but it is not working and shows an array on console.

 constructor(public navCtrl: NavController, public http: Http) 
    .map(response => response.text())
    .subscribe(data => {


Why are you logging this.dato instead of data?


Excuse me after sending I found it and corrected. but still is the same situation.


Just do console.log(data);


Thank you. That is great. when we had to use “this”?


I think your assignment to this.dato is misguided. It looks like you’re expecting that to give this.dato the response that is coming back from the backend. It isn’t. It’s assigning the Observable representing the HTTP request. I’m almost positive that’s not what you want to do; instead you likely want:

.subscribe((data) => {
  this.dato = data;