title: node.js cookie with request.jar
body: <p>Im scraping a site, that requires authentication. I'm using node.js and request with a jar to store the cookie. </p>
  
  <p>My problem:
  I got two routes /login and /api, when i login to the website i store the cookie in the login route/file how can i then use the same cookie in /api?</p>
  
  <pre><code>        login.js:
  
          var request = require('request');
          var jar = request.jar();
  
          var payload = querystring.stringify({
              username: username,
              password: password,
              request_token: token,
          });
  
          var options = {
              ..
              ..
              method: 'POST',
              body: payload,
              jar: jar &lt;---------- Valid cookie
          };
  
         request(options, function (error, response, body) {
              // Code here
          });
  
  
         --------------------------------
  
          api.js:
  
          var request = require('request');
          var jar = request.jar();
  
             var options = {
              method: "get",
              url: baseUrl,
              jar: jar &lt;-------- Not sat anymore
          };
  
  
          request(options, function (error, response, body) {
  
              if (error) {
                  res.send(error);
                  return;
              }
  </code></pre>