Re: Example: http get a page?
Posted: Thu Oct 22, 2015 12:09 pm
Thanks kolban,
I think I am beginning to understand this new way of thinking (I am used to Arduinos procedural way of doing things)
So do you think this is the way to do it ?:
I think I am beginning to understand this new way of thinking (I am used to Arduinos procedural way of doing things)
So do you think this is the way to do it ?:
Code: Select all
ESP8266WiFi.init();
var hostname="www.eecs.mit.edu";
ESP8266WiFi.getHostByName(hostname, function(ipAddress){
var http = require("http");
http.get({host: ESP8266WiFi.getAddressAsString(ipAddress), port: 80, path: "/"},
function(response) {
print("get callback!");
response.on('data', function(data) {
print(data);
});
response.on('close', function() {
print("The response connection closed");
});
});
});