samedi 4 août 2018

How to handle 404 as json response if route not found?

Using Laravel 5.4, I would like to send the json response, while there is no route found in api.php, how can I archive with in api.php and without Controller and Model class.

Tried with fallback :

Route::fallback(function(){
    return response()->json(['message' => 'Not Found!'], 404);
});

Error for above :

Attribute [fallback] does not exist.

Please help me, how to handle this 404 issue.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire