Rest Slim php的angular 2应用程序响应为net::ERR_EMPTY_响应
为什么我会在chrome控制台中收到这样的错误消息: 选项网络::ERR\u EMPTY\u响应 异常:URL为null的状态为0的响应Rest Slim php的angular 2应用程序响应为net::ERR_EMPTY_响应,rest,angular,slim,Rest,Angular,Slim,为什么我会在chrome控制台中收到这样的错误消息: 选项网络::ERR\u EMPTY\u响应 异常:URL为null的状态为0的响应 未捕获响应{u body:ProgressEvent,状态:0,ok:false,statusText:,headers:headers…}这似乎是如何处理响应的问题。什么是HttpResponse 处理响应的一种典型方法是使用现有的响应对象并写入该对象 Hi everyone, this is the code in slim php:
未捕获响应{u body:ProgressEvent,状态:0,ok:false,statusText:,headers:headers…}这似乎是如何处理响应的问题。什么是HttpResponse 处理响应的一种典型方法是使用现有的响应对象并写入该对象
Hi everyone,
this is the code in slim php:
$app->post('/checkSignIn', function () use ($app) {
$params = $app->request->post()['body'] ;
if(!empty($params))
{
$jsonRequest = json_decode($params);
//echo $jsonRequest->email;
$delikatesDbConnect = new DelikatesDbConnect ('localhost', 'gontar_delikates', 'DgDgDg11', 'gontar_delikates');
$id = $delikatesDbConnect->findUserIdByMail($jsonRequest->email);
//echo $id;
if ($id>0) // if $id exists fetch hashed password and email_verfied values
{
$hashed_password = $delikatesDbConnect->findPasswordById($id);
$email_verified = $delikatesDbConnect->findEmailVerifiedById($id);
if (password_verify($jsonRequest->password,$hashed_password) and ($email_verified))
{
$arr = $delikatesDbConnect->json_user_details($id);
$jsonResponse = json_encode($arr);
$response = new HttpResponse($jsonResponse,202);
return $response;
}
else
{
return '';
}
}
else
{
return '';
}
}
else
{
return '';
}
})->name('register');
this is the request code in typscript ng2:
sendUserAndPass(userDetails:JSON)
{
const body = JSON.stringify(userDetails);
console.log(body);
const headers = new Headers();
headers.append('Content-Type','application/json');
this.http.post("http://www.delikates.co.il/backend/checkSignIn", body, {headers: headers})
.subscribe((data:Response)=>console.log(data));
}
当我通过简单的html表单进行检查时,php程序会输入重要的if语句:if(password\u verify($jsonRequest->password,$hashed\u password)和($email\u verifyed)){$arr=$delikatesDbConnect->json\u user\u details($id);$jsonResponse=json\u encode($arr);$response=newhttpresponse($jsonResponse,202);return$response;}thanx我的朋友,在程序中,$response是什么,问题不是更进一步了吗。我最终从$params中检索到了我想要检索的内容。无论如何,我用您建议的命令替换了该命令,但它不起作用。问题在于:if(password\u verify($jsonRequest->password,$hashd\u password)和($email\u verifyed)){//echo“good”$arr=$delikatesDbConnect->json_user_details($id);$jsonResponse=json_encode($arr);$response=new-HttpResponse($jsonResponse,202);return$response;}很抱歉我误读了这个问题。我会删除。您使用的是Slim 2还是Slim 3?如何了解哪个版本是我的Slim?我打开了服务器上所有其他文件中的许可证文件,但其中未指定版本
return $response->withJson($arr, 202);