title: Node.js Lambda Function "response is invalid" Amazon Alexa
body: <p>UPDATE: I had a mistake on my http request endpoint. I had not set the appropriate authentication options so that fixed a lot of errors possibly this specific one. </p>
  
  <p>My question is similar to one here: </p>
  
  <p><a href="https://stackoverflow.com/questions/42704123/node-js-lambda-function-returns-the-response-is-invalid-back-to-alexa-service">Node.js Lambda function returns &quot;The response is invalid&quot; back to Alexa Service Simulator from REST call</a></p>
  
  <p>However the solution to that question does not solve my problem. So I make an http request call to an xsjs service in Hana cloud. I am getting the 'response is invalid' error message. I can't see why. Here is my function: </p>
  
  <pre><code> // Create a web request and handle the response.
  function httpGet(query, callback) {
  
      console.log("/n QUERY: "+ query);
  
      var host = 'datacloudyd070518trial.hanatrial.ondemand.com'; 
      var path = '/LocationInformation/getLocationInfo.xsjs?location='; 
      var hostname = 'https://' + host + path + query; 
  
  
      var auth = 'user1:D1anafer'; 
  
      var req = http.request({'hostname': hostname,
                              'auth': auth
                          }, (res) =&gt; {
  
      var body = '';
  
          res.on('data', (d) =&gt; {
              body += JSON.stringify(d);
          });
  
          res.on('end', function () {
              callback(body);
          }); 
  
      }); 
  
  
      req.end();
  
      req.on('error', (e) =&gt; {
          console.error(e);
      }); 
  
  
  }
  </code></pre>
  
  <p>And the function that calls it: </p>
  
  <pre><code>'getNewsIntent': function () {
  
      //self = this; 
  
      httpGet(location, function (response) {
  
          // Parse the response into a JSON object ready to be formatted.
          //var output = JSON.parse(response); 
          //output = output['change']; 
          var output = response; 
  
          var cardTitle = location; 
          var cardContent = output; 
  
          alexa.emit(':tellWithCard', output, cardTitle, cardContent);
  
      }); 
  
  }, 
  </code></pre>
  
  <p>Thank You 
  -Diana </p>