Avatar for dumdum

dumdum

Member since Sep 2020 • Last active Sep 2020
  • 0 conversations
  • 4 comments

just another programmer in the multi-verse of multi language multi platform

Most recent activity

  • in JavaScript
    Avatar for dumdum

    a bit more than 5 lines actually

    const app = require('express')();
    
    app.get('/', (req, res) => {
      console.log("fetching ...", req.query.url);
      if (req.query.url) fetch(req.query.url, (data) => {res.send(data); });
      else res.send("missing url");
    });
    
    const port = 9999;
    
    app.listen(port, () => {
      console.log(`fetch a url with http://localhost:${port}?url=https://som­ewhere.com/this-that`);
    });
    
    function fetch(url, cb) {
      require("https").get(url, res => {
        res.setEncoding("utf8");
        let body = "";
        res.on("data", data => { body += data; });
        res.on("end", () => { cb(body); });
      });
    }
    
  • in JavaScript
    Avatar for dumdum

    thanks @MaBe, but I already wrote a simple node 5 liner that fits my needs ;)

  • in JavaScript
    Avatar for dumdum

    this thread is old, but just thought it's worth while stressing what @Gordon mentioned above:
    you can't perform a REST API call on a 'cheap' ESP8266 board, you'll need one of the boards that supports this.
    I actually like the idea of developing with the more expensive Wifi board, but I'd like to deliver them cheap boards of 2$ ESP8266 - and that (apparently) can't be used - unless you write and hosts an http to https proxy somewhere - not that hard really :) and you can still stay free with platforms like heroku

    ------- edit ----------
    btw - these boards DO support Firebase if you went along the C++ standard Arduino IDE, just far less fun coding on those

Actions