我在JWT中使用spring boot。创建API 客户端角度调用API。
getAllPost(): Observable<any> {
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'H-auth': localStorage.getItem('H-Token')
})
};
return this.http.get(API.SERVER + '/posts.find', httpOptions);
}
localStorage.getItem( 'H-令牌')= 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJldm5pdFxcYWFhIiwiYXV0aCI6W3siYXV0aG9yaXR5IjoiUk9MRV9BRE1JTiJ9XSwiaWF0IjoxNTc2MjE5NTI5LCJleHAiOjE1NzYzMDU5Mjl9.NFAUYwcHrgklqBh-KVsY9K4E8GXAjV8X090SwK59Lqk'
运行角度应用 调用API字符串bearerToken = req.getHeader(“ h-auth”); -> ==空;
我通过APP呼叫“高级REST客户端-Google Chrome”
帮帮我。 谢谢