找不到结果404

时间:2020-10-03 19:59:45

标签: laravel

客户端错误:GET http://127.0.0.1:8000/api/groups导致 404 Not Found回复:

每当我尝试从API获取数据时,都会显示此错误,但是当我尝试从API获取相同数据时,它将完美显示所有数据

这是API代码 控制器:

 $mat_cens = \DB::SELECT('SELECT * FROM dbo.Master1 WHERE MasterType = 11');
        return response()->json(['mat_cens'=>$mat_cens]);

中间件:

$token = $request->header('App_KEY');
        if($token != 'QAWLhIK2p5'){
            return response()->json(['message'=>'Unauthorized'], 401);
        }
        else{
            return $next($request)
             ->header('Access-Control-Allow-Origin', '*')
             ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
            ->header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, X-Token-Auth, Authorization');
        }

这是我想要API数据的应用代码

控制器:

 $client = new Client();
      $body['headers'] = array('APP_KEY'=>'QAWLhIK2p5');
      $response = $client->request('GET','http://127.0.0.1:8000/api/groups',$body);
      dd($response->getStatusCode());

      $data = $response->getBody();
      dd(json_decode($data));

请帮助我解决此问题 任何帮助将不胜感激.......

我正在添加可以正常工作的邮递员部分图片: enter image description here

,这里是laravel错误页面: enter image description here

0 个答案:

没有答案