title: Change the HTTP status code with a Google Cloud Function Promise
body: <p>My code checks if a user is authorized, if the user is, the proper code is run. If the user is not, it run <code>reject()</code> to reject the promise.</p>
  
  <p>If I run the code authenticated, I get </p>
  
  <p><code>{"error":{"status":"INVALID_ARGUMENT","message":"Bad Request"}}</code></p>
  
  <p>I am trying to change the status code to Forbidden (code 403) which you would normally do with <code>res.status(403)</code> however since this is a promise it is different. How can I change the error code returned?</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>const cloudFunction = functions.https.onCall((data, context) =&gt; {
      return new Promise(function(resolve, reject) {
          auth.verifyIdToken(data.userId).then(function(decodedToken) {
              if(claims.admin === true) {
                  // Run code if user has admin role
              }
              else {
                  reject()
                  // Return error code 403 because user does not have admin role
              }
          }).catch(err =&gt; reject(err)) // Return error code 401 because user is not logged in
      })
  });
  </code></pre>