title: Writing image to local server
body: <p><strong>Update</strong></p>
  
  <p>The accepted answer was good for last year but today I would use the package everyone else uses:
  <a href="https://github.com/mikeal/request" rel="noreferrer">https://github.com/mikeal/request</a></p>
  
  <hr>
  
  <p><strong>Original</strong></p>
  
  <p>I'm trying to grab google's logo and save it to my server with node.js.</p>
  
  <p>This is what I have right now and doesn't work:</p>
  
  <pre><code>        var options = {
              host: 'google.com',
              port: 80,
              path: '/images/logos/ps_logo2.png'
          };
  
          var request = http.get(options);
  
          request.on('response', function (res) {
              res.on('data', function (chunk) {
                  fs.writeFile(dir+'image.png', chunk, function (err) {
                      if (err) throw err;
                      console.log('It\'s saved!');
                  });
              });
          });
  </code></pre>
  
  <p>How can I get this working?</p>