在mean4应用程序中,我登录并获得了安息。
如何使用组件中的数据
login(currenuser){
this.http.post(`http://localhost:3000/users/login`,currenuser,{responseType: 'text'})
.subscribe((data:any) => {
// this.userToComponent=data;
// console.log(this.userToComponent)
}
)
}
答案 0 :(得分:0)
为您服务:
login(currenuser){
return this.http.post(`http://localhost:3000/users/login`,currenuser {responseType: 'text'})
.map(
(response: Response) => {
return {response : response}
});
现在在您的component.ts中订阅响应
constructor(private router: Router, private loginService: LoginService) {}
login(){
this.loginService.login(currenuser)
.subscribe(
response => {
console.log(response)
});
}