title: Handling error in HTTP POST
body: <p>I have code that hits a <code>POST</code> URL and receives the data. Below is the code:</p>
  
  <pre><code>var postdata="{u:1}";
  var options = {
                   host: 10.0.0.1,
                   port: 80,
                   path: /ddd,
                   method: post
              };
  var reqClient = http.request(options, function(res)   
              {
  
                    var data = '';
                    res.setEncoding('utf8'); 
              });
   //setting the request contenet type to application/json
              reqClient.setHeader('Content-Type','application/json');
              //Posts the data to the Server
              reqClient.write(postData);
              reqClient.end();
  reqClient.on('response', function (res) 
                  {   
                        var data = '';
                        res.on('data', function (chunk) 
                        {   
                              data+=chunk;                            
                        });
  res.on('end',function(){
  //Perform some functions
  });
  }).on('error', function(){
                          //error handler
                      }); ;
  </code></pre>
  
  <p>I have to handle an error, say when the server is not able to hit the client URL. Can I follow the above approach? I am stuck here.</p>