Skip to content

Instantly share code, notes, and snippets.

@jxson
Created October 13, 2011 20:30
Show Gist options
  • Select an option

  • Save jxson/1285427 to your computer and use it in GitHub Desktop.

Select an option

Save jxson/1285427 to your computer and use it in GitHub Desktop.
http-browserify example
http = require('http');
var options = {
host: 'localhost',
port: '1337',
path: '/',
// NOTE: Headers can't be set until after the xhr is opened
// https://github.com/substack/http-browserify
// headers: {
// 'Accept': 'application/json'
// 'origin': 'http://localhost:8080'
// }
}
http.get(options, function(response){
response.on('data', function(buffer){
console.log('buffer', buffer);
});
response.on('end', function(){
console.log('data', response);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment