I do not come with a background in web apps, I'm trying to fix this issue on a project where a route is called in a function call and sometimes it says "404 not found" all tho it exists in route:list.
This is the function call as follows:
function call_api($method,$req){
$client = new \GuzzleHttp\Client();
$url = env('APP_URL')."api/".$method;
$myBody = $req;
$response = $client->post($url,['form_params'=>$myBody]);
$result_array = json_decode((string) $response->getBody());
$cont = $result_array;
return $cont;
}
route controller:
public function web_category_list(Request $request){
try{
$news_details= Category::orderBy('id','desc')->post();
$result['error_code'] = '200';
$result['data'] = $news_details;
return response()->json($result);
}
catch (Exception $e) {
return response(['message' => $e->getMessage(), 'error_code' =>'404']);
}