服务错误404(未找到)

时间:2018-04-05 15:44:30

标签: mysql angular service

嗨开发人员我试图从我的数据库中获取数据有效,如果用户存在于表中,那么在下一个停止时我将为他创建一个会话,但是当我尝试测试http请求是否有效时当我的REST API工作正常时,我总是被阻止购买此错误

auth.service.ts

getetudiant(username, password) {
       return this.http.get('localhost/Admin/src/api/api.php?action=auth&username=' + username + '&password=' + password)
            .map(res => res.json());
}

控制器:

recuperation(username, password) {
        this.authService.getetudiant(this.username, this.password)
            .subscribe((data: any) => {
                this.donnee = data;
                console.log(data);
            }, error => {
                console.log(error);
            });
    }

这是API

 $username=$_GET['username'];
    $password=$_GET['password'];


    $query="Select* from admin where id_admin='$username'and pass_admin='$password'";
    $result=$db->query($query);
    $response=[];
    if(mysqli_num_rows($result)>0)
    {
        $response['status']='loggedin';
        $response['user']=$username;

    }else{
        $response['status']='error';
    }
    echo json_encode($response);
  

GET   http://localhost:4200/localhost/Admin/src/api/api.php?action=auth&username=charfedinne&password=amri   404(未找到)

     

index-component.component.ts:29响应{_body:“↵↵↵↵↵↵”,状态:404,   ok:false,statusText:“Not Found”,header:Headers,...}

如果有人可以提供帮助,我将非常感激

1 个答案:

答案 0 :(得分:0)

我猜您使用了错误的网址,请通过postman工具检查网址。 如果您的网址是正确的,那么您将获得此结果。

  1. check port
  2. 检查API和操作名称
  3. 参考:https://en.wikipedia.org/wiki/HTTP_404