错误200状态确定

时间:2018-04-18 14:32:56

标签: angular typescript

我尝试登录我的应用程序,我得到响应200但它的有效: 消息200,状态OK,ok:false。什么意思ok:false?我该如何处理这个问题?这是我以角度发布登录的代码:

public callLogin(username, password): Observable<HttpResponse<any>> {
const observable = new Subject<HttpResponse<any>>();
const formData: FormData = new FormData();
formData.append('username', username);
formData.append('password', password);
this.http.post('/login', formData, {observe: 'response'})
  .subscribe(res => {
      console.log('hello, I am a result ',res);
      this.currUser= someFactory.fromObject(res.body['some']);
      sessionStorage.setItem(this.CURR_USER, JSON.stringify(this.currUser));

      observable.next(res);
    },
    err => {
      sessionStorage.removeItem(this.currUser);
      this.errorHandler(err);
    }
  );
return observable;
 }

  private errorHandler(error: Error | any): Observable<any> {
  console.error(`Error: ${error.status} ${error.statusText} ${error.name}`);
  return Observable.throw(error);
 }

0 个答案:

没有答案