我嘗試從Angular 4發送POST請求到我的Laravel後端。Angular HttpClient「解析期間的Http失敗」
我的login服務具有此方法:
login(email: string, password: string) {
return this.http.post(`http://10.0.1.19/login`, {email, password})
}
我認購我LoginComponent這種方法:
.subscribe(
(response: any) => {
console.log(response)
location.reload()
},
(error: any) => {
console.log(error)
}
)
這是我Laravel後端方法:
...
if($this->auth->attempt(['email' => $email, 'password' => $password], true)) {
return response('Success', 200);
}
return response('Unauthorized', 401);
我的鉻開發工具說,我的請求是一個成功的200狀態代碼。但我的角碼觸發error
塊,給我這個消息:
"Http failure during parsing for http://10.0.1.19/api/login"
如果我從我的後端,它的工作原理返回一個空數組...所以角度試圖分析我的反應到JSON?我如何disble這個?