Mohan Gopi Mohan Gopi - 1 year ago 78
HTTP Question

HTTP observable returns undefined/null

i have created providers page and i am having my post and get request in it

here is my services which returns observable

post(url: string,data:any): Observable<any>{

.map((result:Response)=> {

here is my component code

this.logger.debug("checking data of success " +JSON.stringify(result));


here my result is giving me undefined

in my services if i map like this it works fine

if i apply bracket i am getting undefined.

can some one help me in understand the observable i have checked in but i am feeling difficult to understand there

Answer Source

The short form returns the result of expression implicitly

(param) => expression;

The long form with brackets supports multiple statements but you have to explicitly return

(param) => { 
  let x = this.doSomething();
  return x; 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download