gpt4 book ai didi

HTTP observable 返回 undefined/null

转载 作者:可可西里 更新时间:2023-11-01 17:00:26 25 4
gpt4 key购买 nike

我已经创建了供应商页面,我正在发帖并在其中收到请求

这是我的返回可观察的服务

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

return this.http.post(this.configurator.restServerBaseUrl+url,data)
.map((result:Response)=> {
result.json()
})
}

这是我的组件代码

 submit(){
this.rest.post('/validateUser',validateUserObj)
.subscribe((result)=>{
this.logger.debug("checking data of success " +JSON.stringify(result));

});
}
}

我的结果是 undefined

in my services if i map like this it works fine .map((result:Response)=>result.json())

如果我应用括号,我将变得不确定。

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

最佳答案

简写形式隐式返回expression的结果

(param) => expression;

带括号的长格式支持多条语句,但你必须显式return

(param) => { 
let x = this.doSomething();
return x;
}

关于HTTP observable 返回 undefined/null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40908126/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com