title: Formatting a response in Laravel
body: <p>I'm using <code>GrahamCampbell/Laravel-Bitbucket</code> in my application built on <code>laravel 5.5</code>, where I'm facing some problem, I'm trying to retrieve list of commit details for my repository and I'm unable to use the response format. I'm trying to do something like this:</p>
  
  <pre><code>$data = Bitbucket::api('Repositories\Commits')-&gt;all('***repo***user***', '***repo***name***', array(
          'branch' =&gt; 'master'
      ));
  return $data
  </code></pre>
  
  <p>I've already tried <code>return response()-&gt;json(['data' =&gt; $data], 200)</code></p>
  
  <p>I'm getting a response which is not in JSON format:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Server: nginx
  Vary: Authorization
  Vary: Accept-Encoding
  Content-Type: application/json; charset=utf-8
  Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
  Date: Tue, 13 Feb 2018 09:21:41 GMT
  X-Served-By: app-139
  ETag: "7b8332218b7bc6b7c4a2f50e3ab9c45c"
  X-Static-Version: 476dd7889f1a
  X-Content-Type-Options: nosniff
  X-Accepted-OAuth-Scopes: repository
  X-Credential-Type: password
  X-Render-Time: 1.31000494957
  Connection: keep-alive
  X-Request-Count: 141
  X-Frame-Options: SAMEORIGIN
  Last-Modified: Mon, 12 Feb 2018 20:17:03 GMT
  X-Version: 476dd7889f1a
  Content-Length: 71360
  
  
  {"pagelen": 30, "values": [{"hash": "********9b580ff91967547d61*****", "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/********/*****"}, "html": {"href......
  </code></pre>
  
  <p>I mean headers data is also coming, if I use <code>json_decode($data)</code> it is gives me error which clearly shows is not a JSON. How can I format this to a proper JSON response?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Please check the screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/KNHdg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KNHdg.png" alt="biterror"></a></p>
  
  <p>I'm getting the above code whole thing in response, which is unable to be formatted as it includes header data.</p>