How to deal with non-JSON return?

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

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

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

1 Like

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

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