Created
October 13, 2011 20:30
-
-
Save jxson/1285427 to your computer and use it in GitHub Desktop.
http-browserify example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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