title: How can I send a custom response from a firebase cloud function?
body: <p>I've written a firebase cloud function and everything works as expected, however when trying to read the response from the client side, the data I've returned from the cloud function isn't included in the response.</p>
  
  <p>Here's my cloud function:</p>
  
  <pre><code>exports.employeeExists = functions.https.onRequest((request, response) =&gt; {
    return response.status(500).json({
      data: {
        type: constants.REQUEST_ERROR,
        error: 'ERROR MESSAGE'
      }
    });
  });
  </code></pre>
  
  <p>Here's my client-side request:</p>
  
  <pre><code>
  fetch('cloud function url', options)
        .then((response) =&gt; {
          console.log(JSON.stringify(response));
  });
  
  </code></pre>
  
  <p>The output I get on the client-side log is the response with the correct status code that I've set (500), however the data that I send with the response isn't present.</p>
  
  <p>Is there something I'm missing?</p>