Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

http is undefined

$
0
0

Hello everyone! I am executing this code but I do not understand what is wrong.

Error: TypeError: http is undefined at /index.html line 875 > Function (line 58)

app/index.js

var http = require('http');
 
var options = {
  host: "http://www.example.com",
  port: 80,
  path: '/resource?id=foo&bar=baz',
  method: 'POST'
};
 
http.request(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
  res.setEncoding('utf8');
  res.on('data', function (chunk) {
    alert('BODY: ' + chunk);
  });
}).end();

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>