0
我有一个验证用户的问题。如果凭证(电子邮件和密码)出现问题,我会显示一条包含敬酒的错误消息。但从今天上午开始,我出现了401未经授权的错误,因此吐司不再显示错误消息。我不明白它来自哪里。401 Ionic 2中POST请求的未授权错误?
控制台的错误
POST UrlAPI 401 (Unauthorized)
EXCEPTION: Response with status: 401 Unauthorized for URL: UrlAPI
这是我的POST请求
return this.http.post(link, data, options)
.map((res: Response) => res.json())
.subscribe((response) => {
console.log("RESPONSE: ", response);
if (response.status === 'ok'){
this.UserData.setSessionId(response.session_id);
console.log("SESS_ID SAVED", this.UserData.getSessionId());
this.nav.setRoot(TabsPage);
}
else {
let toast = this.toastCtrl.create({
message: response.errors,
duration: 3000,
position: 'top'
});
toast.present();
}
});
效应初探头
Access-Control-Allow-Origin:*
Cache-Control:no-cache
Connection:Keep-Alive
Content-Length:57
Content-Type:application/json
Date:Tue, 23 May 2017 13:49:56 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.10 (Debian)
请求头
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:16
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host: UrlAPI
Origin:http://localhost:8101
Referer:http://localhost:8101/?ionicplatform=ios&ionicstatusbarpadding=true
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36