Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4802

How do you force a JSON response on every response in Laravel?

$
0
0

I'm trying to build a REST api using Laravel Framework, I want a way to force the API to always responed with JSON not by doing this manulaly like:

return Response::json($data);

In other words I want every response to be JSON. Is there a good way to do that?

Update: The response must be JSON even on exceptions like not found exception.


Viewing all articles
Browse latest Browse all 4802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>