Angular 2不包括标题

时间:2017-05-16 07:57:16

标签: angular cors

我尝试连接redmine Api但是角度可能不包括我的标题,或者由于CORS问题我在请求中看不到它们。 这是我的代码

    login(user: User): Observable<boolean> {
    var headers: Headers = new Headers();
    headers.set('Authorization', "Basic " + btoa(user.login + ":" + user.password));
    headers.set("Content-Type", "application/json");
    headers.set("Cache-Control", "no-cache");
    let options = new RequestOptions({ headers: headers});
    return this.http.get("https://redmine.ourDomain.net/issues.json", options)
        .map((response: Response) => {
            debugger;
            if (response.status == 200) {
                // set token property

                // store username and jwt token in local storage to keep user logged in between page refreshes
                localStorage.setItem('currentUser', JSON.stringify({ user }));

                // return true to indicate successful login
                return true;
            } else {
                // return false to indicate failed login
                return false;
            }
        });
}

和ss请求在浏览器中的显示方式 enter image description here

0 个答案:

没有答案