You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Thanks... I'll try and update the docs. Basically:

    • function(res) is called when the connection is established
    • on('data') is called when there's a chunk of data (this almost certainly will be more than once)
    • on('close') is called when the connection closes.

    The HTTP image loader example does this:

      require("http").get("http://www.espruino­.com/images/espruino_84_48_1bpp.bmp", function(res) {
        var bmpString = "";
        res.on('data', function(data) { bmpString += data; });
        res.on('close', function() { 
          var img = require("BMPLoader").load(bmpString);
          // ...
        });
      });
    
About

Avatar for Gordon @Gordon started