404 json laravel
To do that, we need to add this logic to the app/Exceptions/Handler.php class:
use Illuminate\Database\Eloquent\ModelNotFoundException;
// ...
public function render($request, Exception $exception)
{
if ($exception instanceof ModelNotFoundException && $request->wantsJson()) {
return response()->json(['message' => 'Not Found!'], 404);
}
return parent::render($request, $exception);
}
Also in JavaScript:
- javascript tutorial
- delay in javascript
- convert an array of strings to numbers
- javascript get index of object in array
- js preventdefault
- img src in react js
- class javascript
- email regex javascript
- sort function explained javascript
- react native passing params to nested navigators
- map in javascript
- jquery if is visible
- focus on input field vuejs event
- find longest word in string javascript
- initialize javascript array variable
- js last array element
- js set important style
- npm run test:coverage command in jest
- js find element in array by property
- how to use console.log javascript
- make random letter capital in string javascript
- jquery count elements
- javascript get all script tags on page
- jquery open a new tab