Timeline for How to return string instead of Observable with @angular/http
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 22, 2017 at 9:35 | comment | added | Aakriti.G | if you don't want async calls then use maps in service | |
| Nov 22, 2017 at 9:27 | comment | added | Noob | it’s not running the subscribe | |
| Nov 22, 2017 at 8:51 | comment | added | Aakriti.G | You can use a global variable for that | |
| Nov 22, 2017 at 8:36 | comment | added | Noob | console.log(data) works...i get my expected value. however, the subscribe bit is not working...it is an async call, so assigning to a local variable is not executing that code. var retval: ""; this.service.getCustomerName(value).subscribe( data => { console.log(data); // this works retval = data; }, error => { console.log(error); }); return retval; //undefined here | |
| Nov 22, 2017 at 8:33 | comment | added | Aakriti.G | If we are not returning any JSON object then angular throws an Unexpected token (any alphabet) in JSON at position 0 at JSON.parse () exception. | |
| Nov 22, 2017 at 8:28 | comment | added | Aakriti.G | console data only instead of parsing it in JSON and check what are you getting in the response | |
| Nov 22, 2017 at 8:25 | comment | added | Noob | I get this error. NodeInvocationException: Unexpected token R in JSON at position 0 SyntaxError: Unexpected token R in JSON at position 0 | |
| Nov 22, 2017 at 6:19 | history | answered | Aakriti.G | CC BY-SA 3.0 |