0
我試圖做出一個獲取請求,但不知何故我無法記錄來自後端的承諾。任何想法我做錯了什麼?無法解決承諾
makeLoginCall(_username: string, _password: string) {
let promise = new Promise((resolve, reject) => {
this.http.get('xxx').subscribe(data => {
});
});
return promise;
}
login() {
this.userService.makeLoginCall(this.formLogin.value.username, this.formLogin.value.password)
.then(response => {
console.log(response);
},
(response) => {
if (response.status < 500) {
console.warn('Login failed!');
} else {
console.error('Internal Server Error');
}
});
}
犯錯,你永遠不會調用既不決心(),也沒有拒絕()。 –