title: Laravel Lumen Ensure JSON response
body: <p>I am new to Laravel and to Lumen. I want to ensure I am always getting only a JSON object as output. How can I do this in Lumen?</p>
  
  <p>I can get a JSON response using <code>response()-&gt;json($response);</code>. But when an error happens, API giving me <code>text/html</code> errors. But I want only <code>application/json</code> responses.</p>
  
  <p>Thanks in advance.</p>