ユーザーにログインするために、このtypescriptメソッドがあります。
onSubmit() {
if (this.form.valid) {
this.authService.login(this.form.value).map(res => this.loginResponse = res.json).subscribe(
success => {
console.log('Response: ' + this.loginResponse);
},
error => {
this.loginFailed = true;
setTimeout(()=>{
this.loginFailed = false;
}, 3000);
console.error('ERROR login.component: ' + error);
}
);
}
this.formSubmitAttempt = true;
}
実際、ここで応答データを取得する方法がわかりません。.map(res => this.loginResponse = res)
console.logの出力は次のとおりです。
Response: function () {
if (typeof this._body === 'string') {
return JSON.parse(/** @type {?} */ (this._body));
}
if (this._body instanceof ArrayBuffer) {
return JSON.parse(this.text());
}
return this._body;
}
オブザーバブルを使用して応答オブジェクトを取得する方法について、誰かヒントがありますか。
response.json
関数です。あなたはそれらを呼び出す必要があります
...map( res => this.loginResponse = res.json() )
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加