标签: laravel laravel-5.2 laravel-5.3
当我在URL中调用underined route时,我将Laravel错误视为HTML页面:
GROUP BY
如何在JSON格式响应中替换它?
答案 0 :(得分:2)
您可以在app\Exceptions\Handler.php@render()方法中创建JSON响应:
app\Exceptions\Handler.php@render()
if ($e instanceof MethodNotAllowedHttpException) { return response()->json($data); }
https://laravel.com/docs/5.3/errors#render-method