【发布时间】:2018-12-10 02:48:54
【问题描述】:
在 ionic v3 中,我使用以下代码通过 jwt 插件与 wordpress api 用户交流
我使用波纹管代码进行令牌验证,但它不起作用,在其他情况下,当我在 postman 中测试或通过此标头验证在线请求工具时,我认为它与服务器端无关:
validateAuthToken(token){
return this.http.post(this.API_USER_VALID, {} , {headers: {'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + token}})
.subscribe((validdata)=>{
console.log(validdata);
});
}
错误: Error Image
登录我使用下面的代码,它工作正常 (由 'Content-Type': 'application/json' 标头 不起作用 但带有 'Content-Type': 'application/x-www-form- urlencoded' 工作):
doLogin(username,password){
return this.http.post(this.API_LOGIN,"username=" + username +
"&password=" + password,{headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
.subscribe((ddaa)=>{
console.log(ddaa);
});
}
我卡住了:(,如果有指导请告诉我
【问题讨论】:
-
请查一下CORS,这是你的问题的原因
标签: angular header ionic3 jwt wordpress-rest-api