如何从Angular 5中的响应获取标头

时间:2018-07-16 21:20:55

标签: spring-security angular6

Browser

我如何在代码中获取此信息?,我正在使用angular 6和Spring安全性,但是我需要获取响应的标头中的令牌。

我发帖:

const httpoptions = {
    headers: new HttpHeaders({ 'Content-Type': 'application/json; charset=UTF-8',
        "Access-Control-Allow-Origin": "*",
        "Access-Control-Expose-Headers": "",
        "Access-Control-Allow-Headers": "Content-Type, body, Authorization ",
        "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS"
    })
};

@Injectable({
    providedIn: 'root'
})

export class LogueoService {

    private censoURL = 'http://localhost:8080/login';

    constructor(private http: HttpClient) { }

    inicio (username:string,password:string) {
        return this.http.post<any>(this.censoURL, {username, password }, httpoptions );
    }
}

0 个答案:

没有答案