How to deal with non-JSON return?


#1

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

http://80.75.3.205:8080/.../.../Value:A/Value:B/Value:C

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?\


#2

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


#3

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


#4

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) 
  {
    this.dato=this.http.get('http://80.75.3.205:8080/../../check/3559/3035')
    .map(response => response.text())
    .subscribe(data => {
		console.log(this.dato);
		});
	} 


#5

Why are you logging this.dato instead of data?


#6

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


#7

Just do console.log(data);


#8

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


#9

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;
});