angular - 在 Angular 8 的标头中传递正确的令牌请求时被禁止 403,
问题描述
我正在使用 get 方法在 header 中发送 4 个数据(id、token、ROLE、EMPCODE),
我收到错误
错误 HttpErrorResponse {标头:HttpHeaders,状态:403,状态文本:“禁止”
我的令牌是正确的,我在 Postman 中检查过, 我收到状态为 200 的响应,但我在我的项目中遇到了这个问题
我正在分享我的服务文件代码
employeeData( id , token , role , employeeCode){
let headers = new HttpHeaders();
headers.append('id', id);
headers.append('TOKEN', token);
headers.append('ROLE', role);
headers.append('EMPCODE' , employeeCode);
headers.append( 'Content-Type' , 'application/json');
return this.http.get(this.emp_data, {headers: headers});
}
我正在从订阅获取响应的 Component 共享代码。
viewdetails(){
this.rest.employeeData(this.userId,this.token,this.role, this.employeeCode).subscribe(
result => {
console.log('hello');
console.log(result);
})
}
当我签入浏览器的网络标头时,我可以检查我在请求中传递的标头没有通过那里。
解决方案
推荐阅读
- stripe-payments - 如何区分经常性金额与 Stripe 中的初始金额
- python - 该函数输入一个字符串列表 x 并返回一个整数 ptr
- powershell - 在 Powershell 中生成带有 X.509 证书签名的 JWT
- node.js - NodeJs 用 jsPDF 说“ReferenceError: window is not defined”
- listview - 通过 Adopter 和自定义布局项在 ListView 中显示关联数组
- linux - 执行vertica查询时如何在shell脚本中打印错误?
- javascript - 使用OrbitControls时如何在three.js中禁用鼠标右键移动相机旋转?
- r - 如何创建一个新列表,其中包含 R 中旧列表中的每个单独的矩阵列?
- android - React-native run-android 构建了我的应用程序的正确版本,但 assembleRelease/react-native run-android --variant=release 没有
- jquery - 如何在 Jquery/CSS 中停止加载占位符并显示 div