title: Including JSON in Node.js res.redirect()
body: <p><strong>What specific changes need to be made to the code below so that the JSON contents of the <code>message</code> variable can be sent from the Node.js server to the AngularJS client?</strong></p>
  
  <p>The following code is in the routing file of a Node.js app.  The code below generates JSON and then redirects control to the <code>redirectURL='/'</code> handler, which sends the <code>./public/index.html</code> file to the AngularJS client.</p>
  
  <p>It is important that the JSON <code>message</code> be sent to the AngularJS client in this transaction, so that the AngularJS browser app can be responsible for preserving the user's unique identity.  That way, subsequent requests from AngularJS browser apps can be served by any of hundreds of clones of this Node.js app, and each clone will use the JSON that it receives with each request to connect with a Redis cluster to manage user identity across multiple requests.  This will enable Node.js to not have to remember user identities.  </p>
  
  <pre><code>app.get('/some_endpoint', function(req, res) {
      var redirectURL = '/';
      request.post(otherServerUrl, function(err, response, body){
          if(err){console.log('ERROR with token request.')}
          var data = JSON.parse(body);
          getUser(data.access_token).then(function(message) {
              console.log('in callback, jwtJSON is: ');console.log(message);
              res.redirect(redirectURL);
          });
      });
  });
  
  app.get('*', function(req, res) {
      res.sendfile('./public/index.html'); // load the single view file (angular will handle the front-end)
  });
  </code></pre>
  
  <p><strong>Note that the <code>app.get('*', function(req, res)</code> needs to be able to also serve requests from users that have not been redirected from <code>app.get('/some_endpoint', function(req, res)</code> and who thus do not have any <code>message</code> JSON at the server to be sent to the browser app.</strong></p>