我尝试连接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;
}
});
}