I ran into a little problem in my code that was a bit confusing for me and hope someone can explain why he is doing what he is doing.
Code 1
sendText(){ return this.http.get('/api') .map((response:Response) => response.json()); }
Code 2
sendText(){ return this.http.get('/api').map((response:Response) => { response.json(); }); }
The key difference between the two codes is that in Code 2, I put the brackets after the arrow function to add my tasks to these brackets and to Code 1 . brackets spread and put the task on one line.
My question is why my object goes from the server side, returning as undefined in Code2 using the subscription method, which is angular2, provided that Code1 returns the object I suspect.
source share