```
public function render($request, Exception $exception)
{
    if ( $request->route()->getPrefix() == 'api' ) {
        some code......

        return response()->json($response, $status);
    }

    return parent::render($request, $exception);
}

```

I have a website content site & api both.

I want my exception return json when user request api

If user request is not api, it will return the default page.

But when I put logic into function render, the default one got error.

Anyone know how to fix this?