Laravel: How to serve requests with HTML and JSON (with DRY)
4 min readJan 2, 2021
One of the common problems of a web application is the need to return HTML and JSON to a request. Why? Imagine we have a SPA who needs the responses in JSON, and a backend that needs HTML. In this article, I will show you some ways on how to accomplish this in Laravel.