我尝试从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这个?