Angular2.1.2无法在响应头中获取头

时间:2016-12-13 03:31:55

标签: angular

我对Angular2.1.2有一个问题。我无法在http响应中获得标题。

我在浏览器中有响应标题:

enter image description here

但是我无法在http响应中获得标题:

@echo off
:MENU
title MENU0
Echo 1 - Select Menu 1
Echo 2 - Select Menu 2
Echo 0 - Exit
Echo.


SET /P choice=Type the number or letter of task you want, then press ENTER:
IF %choice%==1 GOTO 1
IF %choice%==2 GOTO 2
IF %choice%==0 EXIT

:1
start %userprofile%\desktop\\Menu1.bat

:2
start %userprofile%\desktop\Menu2.bat

这是我在http响应中看到的标题

enter image description here

它在Angular beta6中工作,当我升级到Angular2.1.2时,它不起作用。
我该如何解决?

1 个答案:

答案 0 :(得分:0)

这取决于你在扔它时是否将响应头传递给你的错误。试试这个

<强>服务

public extractData(res: Response) {
        let body = res.json();
        return body || { };
}
public handleError (error: any | Response) {
    return Observable.throw(error);
}

public postData(): Observable<User[]>{
        return this.http.post(url, body)
            .map(this.extractData)
            .catch(this.handleError)
}

<强>组件

this.yourService.postData(url, body)
   .subscribe(
   (res) => {
   //do something
  }, (err) => {
   let authenticateErr = err.headers.get("WWW-Authenticate");
 //you should have header here
});
相关问题