Courses

Flutter v2 Mobile App with Laravel API

404 page: Accept application/json and Override Error Message

Previous: Show() with RouteModelBinding and Route::apiResource
avatar

Thanks for this tutorial. Would it be ok to add this to api routes 404 errors only? Keeping regular http 404 errors to default 404 web page

public function register() { $this->renderable(function (NotFoundHttpException $e) { if ( request()->is('api/*') ) { return response()->json([ 'message' => 'Object not found' ], 404); } }); }

avatar

Yes, that's one way of doing it. Another way is request()->expectsJson(), from what I remember

avatar
You can use Markdown
avatar

Thanks for this tutotrial!

avatar
You can use Markdown
avatar
You can use Markdown