php - 从 ionic 发送时 api 中的未定义索引授权
问题描述
我正在我的授权标头中将我的 JWT 令牌从本地存储发送到我的 API。一切都在 Postman 上运行,用户被添加到数据库中。但是,在我的 ionic 应用程序中,我不断收到未定义索引的错误。
添加患者
token = this.storage.get('token');
addPatient(FirstName, LastName, InjuryDesc, DOB) {
const headers = new HttpHeaders();
headers.set('Content-Type', 'application/json');
headers.set('Authorization', 'Bearer + this.token');
return this.http.post<any>(apiUrl + 'addPatient.php',
{FirstName, LastName, InjuryDesc, DOB},
{headers});
}
php接口
$headers = getallheaders();
$jwt = $headers['Authorization'];
$response['jwt']= $jwt;
解决方案
推荐阅读
- excel - 带有 VBA 的 Telegram Bot DeleteMessage ID
- vue.js - VueJs // V-for 和 v-modal // 点击按钮后的数据更新问题
- java - STS/Eclipse 未通过 vmargs 运行配置
- c# - 在 Unity 中建立组件之间关系的良好做法是什么?
- php - PHPSpreadsheet 生成错误“INDEX() 函数的参数数量错误:给定 5,预期在 1 到 4 之间”
- knex.js - 如何在 feathers.js/knex 服务中使用 jsonb 运算符“@>”进行搜索
- javascript - 无法弄清楚如何将 Steam Web API 传递给 Int64
- python - 如何删除列表中的最大变量
- javascript - 使用 jquery 函数 .text() 显示格式为 .toLocaleString('fr-FR') 的数字不起作用
- macos - 在 MacOS 上杀死 -9 -1 行为